Advertisement
Guest User

doh

a guest
Oct 22nd, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int gcd (int a,int b){
  5. while (b != 0){
  6. int t = b;
  7. b = a % b;
  8. a = t;
  9. }
  10. return a;
  11. }
  12. int main()
  13. {
  14. int kase;
  15. int a,b,n,i, sum;
  16. cin >> kase;
  17. if(kase > 20)
  18. goto ERR;
  19. for(int j=1;j<=kase;j++){
  20. sum = 0;
  21. cin >> n >> a >> b;
  22. if ((a>=1) && (b>=a) && (n>=b) && (n<(10^12))){
  23. for (int i = a; i<= b; i++){
  24. if (gcd(n,i) == 1){
  25. sum = sum + i;
  26. }
  27. }
  28. cout << sum % 1000000007<<endl;
  29. }
  30. }
  31.  
  32. ERR:
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement