結果
問題 | No.176 2種類の切手 |
ユーザー |
![]() |
提出日時 | 2015-04-03 01:41:53 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,213 bytes |
コンパイル時間 | 591 ms |
コンパイル使用メモリ | 80,992 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-08 02:54:32 |
合計ジャッジ時間 | 1,735 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:44:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 44 | scanf("%lld%lld%lld",&A,&B,&T); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<cstdio> #include<algorithm> #include<vector> #include<queue> #include<string> #include<iostream> #include<cmath> #include<map> #include<set> #include<climits> #include<ctime> #include<complex> #include<sstream> #include<cstring> using namespace std; typedef vector<string>vs; typedef vector<int>vi; typedef vector<vi>vvi; typedef vector<double>vd; typedef pair<int,int>pii; typedef long long ll; typedef pair<ll,ll>pll; typedef vector<ll>vl; #define rrep(i,x,n) for(int i=(x);i<(n);++i) #define rep(i,x) rrep(i,0,(x)) #define fi first #define se second #define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i) #define all(c) (c).begin(),(c).end() #define rall(c) (c).rbegin(),(c).rend() #define pb push_back #define maxs(a,b) (a)=max(a,b) #define mins(a,b) (a)=min(a,b) ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; } ll lcm(ll a,ll b){ return a/gcd(a,b)*b; } int main(){ ll A,B,T; scanf("%lld%lld%lld",&A,&B,&T); ll l=lcm(A,B),g=gcd(A,B); if(T>=l){ printf("%lld\n",(T+l-1)/l*l); return 0; } ll mi=LLONG_MAX; for(int i=0;T-B*i>-B;i++){ mi=min(max((T-i*B+A-1),0ll)/A*A+B*i,mi); } printf("%lld\n",mi); return 0; }