2 solutions

  • 1
    @ 2022-2-1 20:46:16

    #include<bits/stdc++.h> using namespace std; string n;//天数 bool ju(string s,int x) { int sum = 0; for (int i = 0; i < s.size(); i++) { sum = (sum * 10 + s[i] - '0') % x; } if(sum==0) return true; return false; } int main() { int i = 1;//计数器k while (cin >> n) { if (ju(n,73)==true&&ju(n,137)==true) cout << "Case #" << i << ":"<<" " << "YES" << endl; else cout << "Case #" << i << ":" << " "<<"NO" << endl; i++; } return 0; }

    • 0
      @ 2022-3-17 8:39:19
      #include<iostream>//判断数字能否被137或者73整除
      #include<cstring>
      using namespace std;
      const int A[2]={73,137};
      const int N=1e9;
      int len,con=0,p=0;
      char a[N];
      int main()
      {
          while(cin>>a)
          {
          	p++;
          	len=strlen(a);
      		for(int i=0;i<2;i++)
      		{
      			con=0;
      			for(int j=0;j<len;j++)
      			{
      				con=((con*10)+a[j]-'0')%A[i];
      			}
      			if(con==0)
      			{
      				break;
      			}
      		}
      		if(con==0)
      		{
      			cout<<"Case #"<<p<<": YES"<<endl;
      		}
      		else
      		{
      			cout<<"Case #"<<p<<": NO"<<endl;
      		}
          }
          return 0;
      }
      
      • 1

      Information

      ID
      285
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      7
      Tags
      # Submissions
      129
      Accepted
      33
      Uploaded By