結果
| 問題 |
No.928 軽減税率?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-25 20:18:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 925 bytes |
| コンパイル時間 | 2,587 ms |
| コンパイル使用メモリ | 191,684 KB |
| 最終ジャッジ日時 | 2025-01-10 15:38:24 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 WA * 1 RE * 3 |
コンパイルメッセージ
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){
return -1;
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)+1;
for(int x=1;x<100/(q-p);x++) if(p*x/100<q*x/100) ans++;
printf("%d\n",ans);
}
}
return 0;
}