結果

問題 No.1486 ロボット
ユーザー mmn15277198
提出日時 2021-04-24 20:47:21
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 3,553 bytes
コンパイル時間 1,038 ms
コンパイル使用メモリ 107,120 KB
実行使用メモリ 6,784 KB
最終ジャッジ日時 2024-07-04 09:14:27
合計ジャッジ時間 2,494 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <queue>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define vi vector<int>
#define vll vector<long long>
#define vb vector<bool>
#define vs vector<string>
#define all(x) x.begin() , x.end()
#define pb push_back
#define eb emplace_back
#define chmax(x,y) (x) = max((x) , (y))
#define chmin(x,y) (x) = min((x) , (y))
#define fi first
#define se second
#define int128 __int128
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const int MOD = int(1e9) + 7;
//const int MOD = 998244353;
const ll MOD = ll(1e9) + 7;
//const ll MOD = 998244353;
const ld PI = 3.1415926535897932384626;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
const int MX = 220000;
ll modpow (ll x , ll p) {
ll ret = 1;
while (p) {
if (p % 2 == 1) {
ret *= x;
ret %= MOD;
}
x *= x;
x %= MOD;
p /= 2;
}
return ret;
}
vll fact(MX);
vll factinv(MX);
void init_fact () {
fact[0] = 1;
for (int i = 1; i < MX; i++) {
fact[i] = 1LL * i * fact[i - 1] % MOD;
}
for (int i = 0; i < MX; i++) {
factinv[i] = modpow(fact[i] , MOD - 2);
}
}
bool is_prime (int x) {
if (x == 2 || x == 3 || x == 5 || x == 7) {
return true;
}
for (ll i = 2; i*i <= x; i++) {
if (x % i == 0) {
return false;
}
}
return true;
}
vb prime_table(MX , true);
void init_prime() {
for (int i = 2; i < MX; i++) {
for (int j = i + i; j < MX; j += i) {
prime_table[j] = false;
}
}
return;
}
map<ll, int> factrization(ll x) {
map<ll, int> ret;
for (int i = 2; i*i <= x; i++) {
while (x % i == 0) {
ret[i]++;
x /= i;
}
}
if (x > 1) ret[x]++;
return ret;
}
ll moddiv (ll a , ll b) { return a * modpow(b , MOD - 2) % MOD; }
ll modsub (ll a , ll b) { if (a >= b) return (a - b) % MOD; else return (MOD - a + b); }
ll nCk (ll n , ll k) { return ((fact[n] * factinv[k] % MOD) * factinv[n - k] % MOD); }
ll nHk (ll n , ll k) { return nCk(n - 1 + k , k); } // - 1 + boll
ll gcd (ll a , ll b) { if (a < b) swap(a , b); if (a % b == 0) return b; else return gcd(b , a % b); }
ll lcm (ll a , ll b) { return a / gcd(a , b) * b; }
ll lin() { ll x; scanf("%lld" , &x); return x; }
int in() { int x; scanf("%d" , &x); return x; }
bool is_palindrome (string s) { string t = s; reverse(all(t)); return (s == t); }
void io_setup() { cout << fixed << setprecision(15); }
void solve () {
int a , b , c , d , e;
cin >> a >> b >> c >> d >> e;
long long cnt = 0;
int limit = min((a + b) * (c + d) , e);
for (int i = 1; i <= limit; i++) {
if (1 <= i % (a + b) && i % (a + b) <= a && 1 <= i % (c + d) && i % (c + d) <= c) {
cnt++;
}
}
long long ans;
if (e >= (a + b) * (c + d)) ans = e / ((a + b) * (c + d)) * cnt;
else ans = cnt;
cnt = 0;
for (int i = 1; i <= e % ((a + b) * (c + d)); i++) {
if (1 <= i % (a + b) && i % (a + b) <= a && 1 <= i % (c + d) && i % (c + d) <= c) {
cnt++;
}
}
if (e >= (a + b) * (c + d)) ans += cnt;
cout << ans << endl;
return;
}
int main() {
io_setup();
init_fact();
//init_prime();
solve();
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0