Advertisement
raisul82

UVA 11934 - Magic Formula

Jun 12th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int a,b,c,d,L,res;
  6. while(scanf("%d%d%d%d%d",&a,&b,&c,&d,&L)==5)
  7. {
  8. if(a==0&&b==0&&c==0&&d==0&&L==0)
  9. {
  10. return 0;
  11. }
  12. int countt=0;
  13. for(int i=0; i<=L; i++)
  14. {
  15. res=(a*i*i)+(b*i)+c;
  16. if(res%d==0)
  17. {
  18. countt++;
  19. }
  20. }
  21.  
  22. printf("%d\n",countt);
  23. }
  24.  
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement