(题目)超大数取模

  问题描述:假如有一个很大的数,大到10^1000,那么求这个值对17取模的值!

 1 #include <stdio.h>
 2 int main()
 3 {
 4     char num[1001];//char数组存储
 5     int i,ans=0;
 6     gets(num);
 7     for (i=0;num[i]!=‘\0‘;++i)//关键循环
 8         ans=( ans*10+(num[i]-‘0‘) )%17;//模拟的出原意中的数值,每次提前模17是可行的
 9     printf("ans=%d\n",ans);
10     return 0;
11 }

Slove Code

时间: 2024-10-12 19:13:37

(题目)超大数取模的相关文章

uva 10692 Huge Mods 超大数取模

vjudge上题目链接:Huge Mods 附上截图: 题意不难理解,因为指数的范围太大,所以我就想是不是需要用求幂大法: AB % C = AB % phi(C) + phi(C) % C ( B > phi(C) ) 呢?后来发现确实需要用到,而且因为它有很多重指数,所以需要 dfs,深搜到最后一层后才返回,每次向上一层返回用求幂公式处理好的指数,然后本层用同样的原理去处理好当前层取模的值,并向上一层返回.欧拉函数预处理即可,这题的结束也有点卡人,我是用输入挂来处理的. 1 #include

hdoj 4828 卡特兰数取模

Grids Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 93    Accepted Submission(s): 25 Problem Description 度度熊近期非常喜欢玩游戏.这一天他在纸上画了一个2行N列的长方形格子. 他想把1到2N这些数依次放进去.可是为了使格子看起来优美,他想找到使每行每列都递增的方案.只是画了

hunnu11562:The Triangle Division of the Convex Polygon(第n个卡特兰数取模)

Problem description   A convex polygon with n edges can be divided into several triangles by some non-intersect diagonals. We denote d(n) is the number of the different ways to divide the convex polygon. For example,when n is 6,there are 14 different

ACM--大数取模--HDOJ 1212--Big Number--水

HDOJ题目地址:传送门 Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7350    Accepted Submission(s): 5079 Problem Description As we know, Big Number is always troublesome. But it's really im

CodeForces Gym 100935D Enormous Carpet 快速幂取模

Enormous Carpet Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Gym 100935D Description standard input/outputStatements Ameer is an upcoming and pretty talented problem solver who loves to solve problems using computers.

bestcoder#43 1002 在数组中找两个数的和取模的最大值 二分

bestcoder#43 1002 在数组中找两个数的和取模的最大值  二分 pog loves szh II Accepts: 97 Submissions: 834 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description Pog and Szh are playing games. There is a sequence with n number

poj---1995---整数幂取模

先上题目 ~ touch me 以前只做过 矩阵快速幂取模~ 这题是 整数幂取模  差不多 一开始 忘记 拆分成二进制 进行离散了  果断TLE ,... 这边用到的 * + % 这3个运算符 混合运算时 还是很容易搞混的 1 #include <iostream> 2 using namespace std; 3 4 __int64 mod , sum; 5 void solve( int x , int n ) 6 { 7 __int64 result = 1; 8 while( n )

hdu 5109(构造数+对取模的理解程度)

Alexandra and A*B Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 802    Accepted Submission(s): 211 Problem Description Alexandra has a little brother. He is new to programming. One day

hdu 5265 技巧题 O(nlogn)求n个数中两数相加取模的最大值

pog loves szh II Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2106    Accepted Submission(s): 606 Problem Description Pog and Szh are playing games.There is a sequence with n numbers, Pog wi