fork download
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cmath>
  4. #include<cstring>
  5. #include<stdlib.h>
  6. #include<algorithm>
  7. #define getcx getchar_unlocked
  8. #define pc(x) putchar_unlocked(x);
  9. #ifndef ONLINE_JUDGE
  10. #define getcx getchar
  11. #endif
  12. using namespace std;
  13. #define ull unsigned long long int
  14. #define lli long long int
  15. #define li long int
  16. #define ii int
  17. #define mod 1000000007
  18. inline int inp()
  19. {
  20. int n=0;
  21. int ch=getcx();int sign=1;
  22. while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();}
  23.  
  24. while( ch >= '0' && ch <= '9' )
  25. n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
  26. return n*sign;
  27. }
  28.  
  29. inline long long in()
  30. {
  31. long long n=0;
  32. long long ch=getcx();long long sign=1;
  33. while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();}
  34.  
  35. while( ch >= '0' && ch <= '9' )
  36. n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
  37. return n*sign;
  38. }
  39.  
  40. inline void write (lli n)
  41. {
  42. lli N = n, rev, count = 0;
  43. rev = N;
  44. if (N == 0) { pc('0'); pc('\n'); return ;}
  45. while ((rev % 10) == 0) { count++; rev /= 10;} //obtain the count of the number of 0s
  46. rev = 0;
  47. while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;} //store reverse of N in rev
  48. while (rev != 0) { pc(rev % 10 + '0'); rev /= 10;}
  49. while (count--) pc('0');
  50. }
  51.  
  52. int main() {
  53. // your code goes here
  54. lli t,a,b;
  55. t = in();
  56. while ( t-- )
  57. {
  58.  
  59. a= in(); b = in();
  60. printf("%lld\n",(a%mod * b%mod - a%mod - b%mod));
  61. }
  62. return 0;
  63. }
Success #stdin #stdout 0s 3100KB
stdin
2
3 4
5 7
stdout
5
23