Submission #616030


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	vl fs={
		25,
		2525,
		252525,
		25252525,
	};
	for(ll n;cin>>n && n;){
		ll res=0;
		repi(i,1,1<<fs.size()){
			ll x=1;
			rep(j,fs.size()) if(i>>j&1)
				x=x/__gcd(x,fs[j])*fs[j];
			res+=(__builtin_popcount(i)&1?1:-1)*(n/x);
		}
		cout<<res<<endl;
	}
}

Submission Info

Submission Time
Task A - ニコニコ数
User lyoz
Language C++11 (GCC 4.9.2)
Score 60
Code Size 1794 Byte
Status AC
Exec Time 28 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 23 ms 796 KB
sample_02.txt AC 23 ms 800 KB
test_01.txt AC 23 ms 924 KB
test_02.txt AC 24 ms 924 KB
test_03.txt AC 24 ms 796 KB
test_04.txt AC 23 ms 804 KB
test_05.txt AC 23 ms 916 KB
test_06.txt AC 22 ms 928 KB
test_07.txt AC 23 ms 804 KB
test_08.txt AC 23 ms 796 KB
test_09.txt AC 23 ms 804 KB
test_10.txt AC 25 ms 928 KB
test_11.txt AC 22 ms 796 KB
test_12.txt AC 28 ms 928 KB
test_13.txt AC 24 ms 924 KB
test_14.txt AC 23 ms 916 KB
test_15.txt AC 23 ms 800 KB