076

Zero Judge g183. 81倍數判別

076
May 27th, 2024 (edited)
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4.     string s;
  5.     long long a;
  6.     while(cin>>s){
  7.         a=0;
  8.         for(char i:s){
  9.             a+=i-'0';
  10.         }
  11.         if(a%9==0) cout<<"konopad!\n"; else cout<<"konosuba!\n";
  12.     }
  13.     return 0;
  14. }
  15. /*
  16. Zero Judge g183. 81倍數判別
  17. https://zerojudge.tw/ShowProblem?problemid=g183
  18. 2024 May 27
  19. */
  20. /*
  21. //應該是下面的這邊才是對的
  22. #include <iostream>
  23. using namespace std;
  24. int main(){
  25.     string s;
  26.     long long a,t;
  27.     while(cin>>s){
  28.         a=0;
  29.         t=1;
  30.         for(int i=s.length()-1;i>=0;i--){
  31.             a+=t*(s[i]-'0');
  32.             t=(t*10)%81;
  33.         }
  34.         if(a%81==0) cout<<"konopad!\n"; else cout<<"konosuba!\n";
  35.     }
  36.     return 0;
  37. }
  38. */
Advertisement
Add Comment
Please, Sign In to add comment