fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int a,b,c,ans;
  4. int main() {
  5. ios::sync_with_stdio(false);
  6. cin.tie(0),cout.tie(0);
  7. cin>>a>>b>>c;
  8. if(a==1 && b==1){
  9. cout<<c+1;
  10. return 0;
  11. }
  12. for(int i=0;i<=c/a;i++){
  13. for(int j=0;j<=c/b;j++){
  14. if(i*a+j*b==c){
  15. ans++;
  16. }
  17. }
  18. }
  19. cout<<ans;
  20. }
Success #stdin #stdout 0s 5304KB
stdin
1 1 10000000
stdout
10000001