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. {sharepoint}提升 SharePoint 代码执行权限

    提升 SharePoint 代码执行权限 关于如何提升 SharePoint 代码执行权限及相关知识介绍的文章我们园子里有很多, 这里给出其中两篇文章的链接,就不再啰嗦了. http://www.cn ...

  2. SpringMVC实现简单应用

    我们都知道,servlet代码一般来说只能在一个servlet中做判断去实现一个servlet响应多个请求, 但是springMVC的话还是比较方便的,主要有两种方式去实现一个controller里能 ...

  3. 几何+点与线段的位置关系+二分(POJ2318)

    TOYS Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 10666   Accepted: 5128 Description ...

  4. hdu2196 Computer【树形DP】【换根法】

    Computer Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  5. lampp and testrail

    https://wyzx.testrail.net szllq2000 http://129.0.1.228/testrail/ http://docs.gurock.com/testrail-adm ...

  6. ubuntu low graphic mode---disable docker -self start.

    --------- /etc/default/docker.conf-----设置启动参数. /etc/init/docker.conf------------不好使(only mysql) star ...

  7. socketserver源码解析和协程版socketserver

    来,贴上一段代码让你仰慕一下欧socketserver的魅力,看欧怎么完美实现多并发的魅力 client import socket ip_port = ('127.0.0.1',8009) sk = ...

  8. 修改nginx的http响应头server字段

    信息泄露类型:HTTP服务器响应头Server字段信息泄露 示例: 解决: 需要重新对nginx编译安装: [root@localhost ~]# tar zxvf nginx-1.8.1.tar.g ...

  9. Day19 客户关系系统实战

    day19 今日内容 Service事务 客户关系管理系统     Service事务 在Service中使用ThreadLocal来完成事务,为将来学习Spring事务打基础! 1 DAO中的事务 ...

  10. 模块讲解----subprocess模块

    历史 #输出结果到屏幕上,并不返回执行状态os.system('dir')#保存命令的执行结果输出ret = os.popen('dir').read() 问题:上面2条是把命令结果保存下来了,但是返 ...