結果
| 問題 | No.316 もっと刺激的なFizzBuzzをください |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-12-24 02:35:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 835 bytes |
| 記録 | |
| コンパイル時間 | 2,020 ms |
| コンパイル使用メモリ | 193,940 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2025-12-24 02:35:57 |
| 合計ジャッジ時間 | 3,392 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
コンパイルメッセージ
main.cpp: In function ‘void input()’:
main.cpp:19:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | freopen(TASKNAME ".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:20:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | freopen(TASKNAME ".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define I first
#define II second
#define ii pair<int, int>
#define ll long long
using namespace std;
const long long P = 1e9 + 7;
const int N = 1e6 + 10;
const long long INF = 1e18;
void input()
{
#define TASKNAME ""
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if (fopen(TASKNAME ".inp", "r"))
{
freopen(TASKNAME ".inp", "r", stdin);
freopen(TASKNAME ".out", "w", stdout);
}
}
ll a, b, c, t,n;
ll lcm(ll x, ll y)
{
return x/__gcd(x, y)*y;
}
ll dem(ll x, ll a, ll b, ll c)
{
if (x <= 0)
return 0;
ll res = x/a+x/b+x/c+x/(lcm(lcm(a, b), c))-x/(lcm(a, b))-x/(lcm(b, c))-x/(lcm(a, c));
return res;
}
int main()
{
input();
cin >> n >> a >> b >> c;
ll l = 1,r=n;
cout << dem(r, a, b, c)-dem(l-1, a, b, c);
return 0;
}
vjudge1