Submission #616207


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	return (a%b ? gcd(a%b, b) : b);
}

int lcm(int a, int b)
{
	return a / gcd(a, b)*b;
}

void extgcd(long a, long b, long& x, long& y)
{
	if (b != 0) { extgcd(b, a % b, y, x); y -= a / b * x; }
	else { x = 1; y = 0; }
}

int main()
{
	ll a[] = { 25,2525,252525,25252525 };
	ll n; cin >> n;
	ll ans = 0;
	REP(i, 4)
	{
		ans += n / a[i];
	}
	REP(i, 4)FOR(j, i+1, 4)
	{
		ll t = lcm(a[i], a[j]);
		ans -= n / t;
	}
	REP(i, 4)FOR(j, i + 1, 4)FOR(k, j + 1, 4)
	{
		ll t = lcm(lcm(a[i], a[j]), a[k]);
		ans += n / t;
	}
	cout << ans << endl;
	return 0;
}

Submission Info

Submission Time
Task A - ニコニコ数
User amano
Language C++11 (GCC 4.9.2)
Score 60
Code Size 1280 Byte
Status AC
Exec Time 27 ms
Memory 928 KB

Judge Result

Set Name Sample Subtask1
Score / Max Score 0 / 0 60 / 60
Status
AC × 2
AC × 17
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
Subtask1 sample_01.txt, sample_02.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt
Case Name Status Exec Time Memory
sample_01.txt AC 27 ms 700 KB
sample_02.txt AC 24 ms 800 KB
test_01.txt AC 23 ms 796 KB
test_02.txt AC 24 ms 800 KB
test_03.txt AC 24 ms 804 KB
test_04.txt AC 24 ms 800 KB
test_05.txt AC 24 ms 928 KB
test_06.txt AC 26 ms 804 KB
test_07.txt AC 24 ms 800 KB
test_08.txt AC 24 ms 672 KB
test_09.txt AC 23 ms 928 KB
test_10.txt AC 26 ms 804 KB
test_11.txt AC 26 ms 804 KB
test_12.txt AC 25 ms 788 KB
test_13.txt AC 25 ms 800 KB
test_14.txt AC 24 ms 800 KB
test_15.txt AC 26 ms 796 KB