結果
問題 | No.928 軽減税率? |
ユーザー |
|
提出日時 | 2020-05-25 20:23:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 913 bytes |
コンパイル時間 | 2,273 ms |
コンパイル使用メモリ | 191,644 KB |
最終ジャッジ日時 | 2025-01-10 15:38:41 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:8:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | int p,q,a; scanf("%d%d%d",&p,&q,&a); | ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int main(){ int p,q,a; scanf("%d%d%d",&p,&q,&a); if(p==q){ printf("%d\n",a==0?0:int(1e9)); } else if(p>q){ /* floor(p * x / 100) < floor(q * x / 100) + a <= p * x / 100 < q * x / 100 + a - 1 <=> x < (a - 1) * 100 / (p - q) floor(p * x / 100) >= floor(q * x / 100) + a <= p * x / 100 >= q * x / 100 + a + 1 <=> x >= (a + 1) * 100 / (p - q) */ int lb=(a-1)*100/(p-q); if(lb<1) lb=1; int ub=(a+1)*100/(p-q); int ans=lb-1; for(int x=lb;x<ub;x++) if(p*x/100<q*x/100+a) ans++; printf("%d\n",ans); } else{ // p<q if(a>0){ printf("%d\n",int(1e9)); } else{ /* floor(p * x / 100) < floor(q * x / 100) <= p * x / 100 < q * x / 100 - 1 <=> x > 100 / (q - p) */ int ans=1e9-100/(q-p); for(int x=1;x<=100/(q-p);x++) if(p*x/100<q*x/100) ans++; printf("%d\n",ans); } } return 0; }