結果
問題 | No.1358 [Zelkova 2nd Tune *] 語るなら枚数を... |
ユーザー | chocorusk |
提出日時 | 2021-01-22 21:30:33 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 477 ms / 2,000 ms |
コード長 | 1,346 bytes |
コンパイル時間 | 1,206 ms |
コンパイル使用メモリ | 129,848 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-08-27 17:35:08 |
合計ジャッジ時間 | 4,378 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 7 ms
4,380 KB |
testcase_07 | AC | 6 ms
4,380 KB |
testcase_08 | AC | 6 ms
4,380 KB |
testcase_09 | AC | 5 ms
4,376 KB |
testcase_10 | AC | 5 ms
4,380 KB |
testcase_11 | AC | 433 ms
4,376 KB |
testcase_12 | AC | 369 ms
4,380 KB |
testcase_13 | AC | 477 ms
4,376 KB |
testcase_14 | AC | 340 ms
4,380 KB |
testcase_15 | AC | 385 ms
4,380 KB |
testcase_16 | AC | 305 ms
4,380 KB |
ソースコード
#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; } const ll MOD=1e9+7; cout<<ans%MOD<<endl; } return 0; }