結果
問題 | No.1358 [Zelkova 2nd Tune *] 語るなら枚数を... |
ユーザー | chocorusk |
提出日時 | 2021-01-22 21:29:38 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,314 bytes |
コンパイル時間 | 1,168 ms |
コンパイル使用メモリ | 131,356 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-08 13:15:49 |
合計ジャッジ時間 | 4,078 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 7 ms
5,376 KB |
testcase_07 | AC | 5 ms
5,376 KB |
testcase_08 | AC | 5 ms
5,376 KB |
testcase_09 | AC | 5 ms
5,376 KB |
testcase_10 | AC | 5 ms
5,376 KB |
testcase_11 | AC | 391 ms
5,376 KB |
testcase_12 | AC | 330 ms
5,376 KB |
testcase_13 | AC | 430 ms
5,376 KB |
testcase_14 | AC | 302 ms
5,376 KB |
testcase_15 | AC | 348 ms
5,376 KB |
testcase_16 | WA | - |
ソースコード
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #include <fstream> #include <utility> #include <functional> #include <stack> #include <array> #include <list> #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair<int, int> P; ll inv(ll a, ll m){ ll b=m, x=1, y=0; while(b>0){ ll t=a/b; swap(a-=t*b, b); swap(x-=t*y, y); } return (x%m+m)%m; } int main() { int t; cin>>t; while(t--){ ll a[3], y; cin>>a[0]>>a[1]>>a[2]>>y; sort(a, a+3); ll ans=0; ll g=gcd(a[0], a[1]); a[0]/=g, a[1]/=g; ll b0=inv(a[0], a[1]); for(ll i=0; i<=y/a[2]; i++){ ll y1=y-a[2]*i; if(y1%g!=0) continue; y1/=g; if(a[1]==1){ ans+=y1+1; continue; } ll p0=b0*y1%a[1]; if(a[0]*p0>y1) continue; ll p1=(y1-a[0]*p0)/a[1]; ans+=p1/a[0]+1; } cout<<ans<<endl; } return 0; }