fork download
  1. #include<bits/stdc++.h>
  2. #define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  3. #define db double
  4. #define bo bool
  5. #define vo void
  6. #define ch char
  7. #define ll long long
  8. #define str string
  9. #define re return
  10. using namespace std;
  11. str nhan(const str &n1,const str &n2)
  12. {
  13. ll l1=n1.size(),l2=n2.size(),i,j,tich,tong;
  14. str ans;
  15. vector<ll> res(l1+l2,0);
  16. for(i=l1-1;i>=0;i--)
  17. {
  18. for(j=l2-1;j>=0;j--)
  19. {
  20. tich=(n1[i]-'0')*(n2[j]-'0');
  21. tong=tich+res[i+j+1];
  22. res[i+j+1]=tong%10;
  23. res[i+j]+=tong/10;
  24. }
  25. }
  26. for(ll i:res) if(!(ans.empty()&&i==0)) ans.push_back(i+'0');
  27. re ans;
  28. }
  29. str chia(const str &n1, const str &n2)
  30. {
  31. ll m,t;
  32. str res="",c="";
  33. for(ch i : n1)
  34. {
  35. c+=i;
  36. m=stoi(c);
  37. t=stoi(n2);
  38. res+=(m/t)+'0';
  39. c=to_string(m%t);
  40. }
  41. size_t st=res.find_first_not_of('0');
  42. if(st==str::npos) re "0";
  43. re res.substr(st);
  44. }
  45. str mod(const str& n1,const str& n2)
  46. {
  47. ll div=0,m=0;
  48. for(ch c : n2) div=div*10+(c-'0');
  49. for(ch c : n1) m=(m*10+(c-'0'))%div;
  50. re to_string(m);
  51. }
  52. int main()
  53. {
  54. faster
  55. ll n;
  56. cin>>n;
  57. str s=to_string(n),s1=to_string(n+1),s2=to_string(n+2);
  58. s=nhan(s,s1);
  59. s=nhan(s,s2);
  60. s=chia(s,"6");
  61. cout<<mod(s,"2004010501");
  62. re 0;
  63. }
Success #stdin #stdout 0.01s 5288KB
stdin
125603300
stdout
1725074533