大数模拟——K - Large Division LightOJ - 1214

K - Large Division

LightOJ - 1214

大数模拟,记得把符号去掉

 1 #include <iostream>
 2 #include <cstring>
 3 #include <string>
 4 #include <map>
 5 #include <set>
 6 #include <algorithm>
 7 #include <fstream>
 8 #include <cstdio>
 9 #include <cmath>
10 #include <stack>
11 #include <queue>
12 using namespace std;
13 const double Pi=3.14159265358979323846;
14 typedef long long ll;
15 const int MAXN=5000+5;
16 const int dx[5]={0,0,0,1,-1};
17 const int dy[5]={1,-1,0,0,0};
18 const int INF = 0x3f3f3f3f;
19 const int NINF = 0xc0c0c0c0;
20 int main()
21 {
22     int t;cin>>t;int cnt=0;
23     while(t--)
24     {
25         string str;cin>>str;ll n;cin>>n;
26         if(str[0]==‘-‘)
27             str.erase(str.begin());
28         ll sum=0;
29         for(int i=0;i<str.size();i++)
30         {
31             sum=sum*10+str[i]-‘0‘;
32             sum=sum%n;
33         }
34         if(sum==0) printf("Case %d: divisible\n",++cnt);
35             else printf("Case %d: not divisible\n",++cnt);
36
37     }
38     return 0;
39 } 

原文地址:https://www.cnblogs.com/Msmw/p/10991230.html

时间: 2024-08-09 02:24:55

大数模拟——K - Large Division LightOJ - 1214的相关文章

1214 - Large Division -- LightOj(大数取余)

http://lightoj.com/volume_showproblem.php?problem=1214 这就是一道简单的大数取余. 还想还用到了同余定理: 所谓的同余,顾名思义,就是许多的数被一个数d去除,有相同的余数.d数学上的称谓为模.如a=6,b=1,d=5,则我们说a和b是模d同余的.因为他们都有相同的余数1. //// 数学上的记法为: a≡ b(mod d) 可以看出当n<d的时候,所有的n都对d同商,比如时钟上的小时数,都小于12,所以小时数都是模12的同商. 对于同余有三种

LightOJ 1214 - Large Division (大数取余)

1214 - Large Division PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB Given two integers, a and b, you should checkwhether a is divisible by b or not. We know that an integer ais divisible by an integer b if and only if the

light oj 1214 - Large Division 大数除法

1214 - Large Division Given two integers, a and b, you should check whether a is divisible by b or not. We know that an integer a is divisible by an integer b if and only if there exists an integer c such that a = b * c. Input Input starts with an in

LightOJ - 1214 Large Division(同余)

Large Division Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu Submit Status Description Given two integers, a and b, you should check whether a is divisible by b or not. We know that an integer a is divisible by an integer

light oj 1214 - Large Division

1214 - Large Division   PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB Given two integers, a and b, you should check whether a is divisible by b or not. We know that an integer a is divisible by an integer b if and only if

LightOJ 1214(大数相除)

Large Division Description Given two integers, a and b, you should check whether a is divisible by b or not. We know that an integer a is divisible by an integer b if and only if there exists an integer c such that a = b * c. Input Input starts with

HDU 5047 Sawtooth 规律+ C++大数模拟 2014 ACM/ICPC Asia Regional Shanghai Online

题意: 用x个大M 可以把平面分成至多几块. 就是折线切割平面的加强版. 一个简单的递推式 : F(x+1) = 16x+1+F(x) 然后转成通项公式,然后C++ 位压大数模拟 #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> using namespace std; typedef long long ll; const int mod = 1000

BNU 34975 剪纸 折线划分平面问题 大数模拟+规律

题目链接:点击打开链接 最多的情况就是每个直线和当前平面的所有直线都相交 设当前有x根直线 则加入一个type0的直线就能产生 x个交点,两个交点间的线段可以把一个平面划分成2个 就能增加x + 1个平面 再推广 若加入typeY 的直线 先让Y++,表示加入直线的根数 就能增加 (x + 1) * Y -  (Y-1) 加完后 平面上的直线数就增加了Y :即 x+=Y 所以每次加入 X 根 Y类型的直线 则答案增加的情况就是: Y++; ans += (x +1) *Y - (Y-1) ans

HDU ACM 1041Computer Transformation(大数模拟+找规律)

分析:大数模拟和找规律. #include<iostream> using namespace std; char f[1001][501]; /* 从下面的步骤中可以看出,下一步的后半部分是前一步的整个串,所以对于后半部分有f[n]=f[n-1]: 从前半部分和整体可以看出,另一部分有f[n]=f[n-1]-1(奇数步),f[n]=f[n-1]+1(偶数步). step0:1 f[0]=0 step1:01 f[1]=0 step2:10 01 f[2]=1 =2*f[1]+1 step3: