https://vjudge.net/problem/POJ-1047

题意:

给一个整数,它的长度为n,从1开始一直到n和该整数相乘,判断每次结果是否和原来的整数是循环的。

思路:

大整数的乘法。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include<vector>
using namespace std; char s[];
int num[];
int temp[];
int n; bool cacl(int m)
{
int t = ;
for (int i = ; i < n; i++)
{
temp[i] = (num[i] * m + t) % ;
t = (num[i] * m + t) / ;
}
if (t>) return false;
return true;
} bool judge()
{
for (int i = ; i<n; ++i)
{
int k = ;
if (temp[i] == num[])
{
while (k<n &&num[++k] == temp[(i+k) % n]);
if (k == n) return ;
}
}
return ;
} int main()
{
//freopen("D:\\txt.txt", "r", stdin);
while (gets(s))
{
memset(num, , sizeof(num));
n = strlen(s);
for (int i = n - ; i >= ; i--)
{
num[n - - i] = s[i] - '';
}
bool flag = false;
for (int i = ; i <= n; i++)
{
if (cacl(i))
{
if (!judge())
{
printf("%s is not cyclic\n", s);
flag = true;
break;
}
}
else
{
printf("%s is not cyclic\n", s);
flag = true;
break;
}
}
if (!flag)
printf("%s is cyclic\n", s);
}
return ;
}

POJ 1047 Round and Round We Go的更多相关文章

  1. POJ 1047 Round and Round We Go 最详细的解题报告

    题目链接:Round and Round We Go 解题思路:用程序实现一个乘法功能,将给定的字符串依次做旋转,然后进行比较.由于题目比较简单,所以不做过多的详解. 具体算法(java版,可以直接A ...

  2. POJ1047 Round and Round We Go

    题目来源:http://poj.org/problem?id=1047 题目大意: 有一些整数具有这样的性质:它的位数为n,把它和1到n的任意一个整数相乘结果的数字会是原数字的一个“环”.说起来比较抽 ...

  3. POJ 2942Knights of the Round Table(tarjan求点双+二分图染色)

    Time Limit: 7000MS   Memory Limit: 65536K Total Submissions: 13954   Accepted: 4673 Description Bein ...

  4. POJ 1584:A Round Peg in a Ground Hole

    A Round Peg in a Ground Hole Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5741   Acc ...

  5. POJ 2942Knights of the Round Table(二分图判定+双连通分量)

    题目链接 题意:一些骑士,他们有些人之间有矛盾,现在要求选出一些骑士围成一圈,圈要满足如下条件:1.人数大于1.2.总人数为奇数.3.有仇恨的骑士不能挨着坐.问有几个骑士不能和任何人形成任何的圆圈. ...

  6. poj 2942--Knights of the Round Table (点的双连通分量)

    做这题简直是一种折磨... 有n个骑士,骑士之间相互憎恨.给出骑士的相互憎恨的关系. 骑士要去开会,围成一圈坐,相互憎恨的骑士不能相邻.开会骑士的个数不能小于三个人.求有多少个骑士不能开会. 注意:会 ...

  7. Round and Round We Go

    http://acm.hdu.edu.cn/showproblem.php?pid=1313 考查大整数与小整数相乘 #include<iostream> #include<cstd ...

  8. 【HDOJ】1313 Round and Round We Go

    大数乘,果断java A了. import java.util.Scanner; import java.lang.StringBuilder; import java.math.BigInteger ...

  9. Tinkoff Challenge - Final Round (Codeforces Round #414, rated, Div. 1 + Div. 2)

    A: 思路:就是找b,c之前有多个s[i] 代码: #include<stdio.h>#define ll long longusing namespace std;ll a,b,c;in ...

随机推荐

  1. 三、微信小游戏开发 --- 小游戏API调用Platform

    微信小游戏API Platform主要是Egret用于来调用平台的SDK的. 在Egret中使用接口定义Platform. Egret项目中默认的platform值是DebugPlatform. 发布 ...

  2. Nginx配置文件(nginx.conf)配置详解[转]

    转自:http://blog.csdn.net/tjcyjd/article/details/50695922 重新学习,发觉这篇文章写得很详细就摘录了! Nginx的配置文件nginx.conf配置 ...

  3. thinkphp发起网络请求

    常规做法使用CURL方法: private function http_request($url,$data = null,$headers=array()){ $curl = curl_init() ...

  4. 徐州网络赛B-BE,GE or NE【记忆化搜索】【博弈论】

    In a world where ordinary people cannot reach, a boy named "Koutarou" and a girl named &qu ...

  5. 当Web访问性能出现问题,如何深探?

    对运维或开发工程师来说,遇到访问性能问题时,最先需要定位的是问题出现在哪个环节,是网络的问题,服务端的问题,还是客户端的问题? 往往技术人员喜欢把精力放在保障后端服务的可用性方面,而对前端界面是否能正 ...

  6. HDU1530 Maximum Clique dp

    正解:dp 解题报告: 这儿是传送门 又是个神仙题趴QAQ 这题就直接说解法辣?主要是思想比较难,真要说有什么不懂的知识点嘛也没有,所以也就没什么好另外先提一下的知识点QAQ 首先取反,就变成了求最大 ...

  7. CentOS 6.4下Squid代理服务器的安装与配置(转)

    add by zhj: 其实我们主要还是关注它在服务器端使用时,充当反向代理和静态数据缓存.至于普通代理和透明代理,其实相当于客户端做的事,和服务端没有什么关系.另外,Squid的缓存主要是缓存在硬盘 ...

  8. android qq开合表

    qq悬浮列表功能暂未实现 main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/andr ...

  9. [py]class的特殊方法

    类方法 解释 hasattr hasattr(class) getattr - setattr - delattr - - - __getattr__ __setattr__ __delattr__ ...

  10. 深入理解Nginx

    nginx概述 nginx是一款自由的.开源的.高性能的HTTP服务器和反向代理服务器:同时也是一个IMAP.POP3.SMTP代理服务器:nginx可以作为一个HTTP服务器进行网站的发布处理,另外 ...