結果
| 問題 |
No.2280 FizzBuzz Difference
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2023-04-21 23:19:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,469 bytes |
| コンパイル時間 | 1,204 ms |
| コンパイル使用メモリ | 119,460 KB |
| 最終ジャッジ日時 | 2025-02-12 12:32:45 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 WA * 4 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#include <atcoder/math>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
return vector<vector<T>>(n, vector<T>(m, v));
}
template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}
template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
if(v.empty()) {
cout << endl;
return;
}
for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
cout << v.back() << endl;
}
void solve(){
ll m, a, b, k; cin >> m >> a >> b >> k;
ll g = gcd(a, b);
if(k%g != 0){
cout << 0 << endl;
return;
}
m /= g;
a /= g;
b /= g;
k /= g;
if(k > b) {
cout << 0 << endl;
return;
}
if(k == b){
cout << 0 << endl;
return;
}
if(k > a){
cout << 0 << endl;
return;
}
ll l = a*b;
ll iter = m/l;
ll rem = m-(iter*l);
if(k == a){
// 頑張る...
// aの倍数
ll last_a = (m/a)*a;
ll last_b = (m/b)*a;
ll cnt_a = (m/a);
ll cnt_b = (m/b);
ll cnt_only_b = cnt_b-(m/(a*b));
ll ans = m/a-1-cnt_only_b;
if(last_b > last_a) ans--;
cout << ans << endl;
return;
}
ll ans = iter*2;
// a-bのパターン
{
auto [r, lc] = atcoder::crt({0ll, k}, {a, b});
if(r <= rem){
ans++;
}
}
// b-aのパターン
{
auto [r, lc] = atcoder::crt({0ll, k}, {b, a});
if(r <= rem){
ans++;
}
}
cout << ans << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
int t; cin >> t;
while(t--) solve();
}
milanis48663220