Advertisement
a53

NumarMin0

a53
Jan 9th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int n,m,b,r,c,r1,n1,j,i,x[10],t;
  4. char a[1001];
  5.  
  6. void afis(int n1,int u)
  7. {
  8. cout<<1;
  9. c=(n1-1)/1000;
  10. r1=(n1-1)%1000 ;
  11. if(r1==0){c--;r1=1000;}
  12. for(j=1;j<=c;j++) cout<<a;
  13. for(j=1;j<=r1-1;j++) cout<<0;
  14. cout<<u<<'\n';
  15. }
  16.  
  17. int main()
  18. {
  19. cin>>n;
  20. for(i=0;i<=999;i++)a[i]='0';
  21. for(i=1;i<=n;i++)
  22. {
  23. cin>>m>>b>>r;
  24. if(m==1)cout<<r<<'\n';
  25. else
  26. {
  27. switch(b)
  28. {
  29. case 2:
  30. afis(m,r);
  31. break;
  32. case 5:
  33. afis(m,r);
  34. break;
  35. case 10:
  36. afis(m,r);
  37. break;
  38. case 3:
  39. afis(m,(r+2)%3);
  40. break;
  41. case 9:
  42. afis(m,(r+8)%9);
  43. break;
  44. case 6:
  45. afis(m,(r+2)%6);
  46. break;
  47. case 4:
  48. if(m==2) afis(m,(r+2)%4);
  49. else afis(m,r);
  50. break;
  51. case 7:
  52. x[2]=4;
  53. x[3]=5;
  54. x[4]=1;
  55. x[5]=3;
  56. x[0]=2;
  57. x[1]=6;
  58. t=m%6;
  59. afis(m,(r+x[t])%b);
  60. break;
  61. case 8:
  62. if(m==2) afis(m,(r+6)%8);
  63. else if(m==3) afis(m,(r+4)%8);
  64. else afis(m,r);
  65. break;
  66.  
  67. }
  68. }
  69. }
  70. return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement