結果
問題 | No.176 2種類の切手 |
ユーザー |
![]() |
提出日時 | 2016-04-11 15:48:09 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 935 bytes |
コンパイル時間 | 608 ms |
コンパイル使用メモリ | 84,676 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-08 03:41:59 |
合計ジャッジ時間 | 1,565 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
/* -*- coding: utf-8 -*- * * 176.cc: No.176 2種類の切手 - yukicoder */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #include<complex> #include<functional> using namespace std; /* constant */ typedef long long ll; const ll LINF = 1LL << 60; /* typedef */ typedef vector<int> vi; typedef queue<int> qi; typedef pair<int,int> pii; /* global variables */ /* subroutines */ /* main */ // a*x+b*y >= t // x >= (t-b*y)/a int main() { ll a, b, t; cin >> a >> b >> t; ll minsum = LINF; for (ll y = 0;; y++) { ll x = (t - b * y + a - 1) / a; ll sum = a * x + b * y; if (minsum > sum) minsum = sum; if (b * y > t || y > a) break; } printf("%lld\n", minsum); return 0; }