K - Large Division
大数模拟,记得把符号去掉
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-10-09 22:20:56