/ Randle /

记录详情

Accepted

/in/foo.cc: In function 'void put(ll)':
/in/foo.cc:37:33: warning: 'q[1]' may be used uninitialized in this function [-Wmaybe-uninitialized]
  while(top--)putchar('0'+q[top+1]);
                          ~~~~~~~^
# 状态 耗时 内存占用
#1 Accepted 8ms 456.0 KiB
#2 Accepted 11ms 324.0 KiB
#3 Accepted 6ms 324.0 KiB
#4 Accepted 8ms 328.0 KiB
#5 Accepted 8ms 324.0 KiB
#6 Accepted 7ms 324.0 KiB
#7 Accepted 1ms 324.0 KiB
#8 Accepted 1ms 324.0 KiB
#9 Accepted 43ms 324.0 KiB
#10 Accepted 31ms 332.0 KiB

代码

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pr;
const double pi=acos(-1);
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define Rep(i,u) for(int i=head[u];i;i=Next[i])
#define clr(a) memset(a,0,sizeof a)
#define pb push_back
#define mp make_pair
#define putk() putchar(' ')
ld eps=1e-9;
ll pp=1000000007;
ll mo(ll a,ll pp){if(a>=0 && a<pp)return a;a%=pp;if(a<0)a+=pp;return a;}
ll powmod(ll a,ll b,ll pp){ll ans=1;for(;b;b>>=1,a=mo(a*a,pp))if(b&1)ans=mo(ans*a,pp);return ans;}
ll gcd(ll a,ll b){return (!b)?a:gcd(b,a%b);}
ll read(){
	ll ans=0;
	char last=' ',ch=getchar();
	while(ch<'0' || ch>'9')last=ch,ch=getchar();
	while(ch>='0' && ch<='9')ans=ans*10+ch-'0',ch=getchar();
	if(last=='-')ans=-ans;
	return ans;
}
void put(ll a){
	if(a<0)putchar('-'),a=-a;
	int top=0,q[20];
	while(a)q[++top]=a%10,a/=10;
	top=max(top,1);
	while(top--)putchar('0'+q[top+1]);
}
//head
ll ans=0;
int n,m,a[25];
ll Gcd(ll a,ll b){
	if(!b)return a;
	return gcd(b,a%b);
}
void dfs(int dep,ll t,int flag){
	if(t>n)return;
	if(dep==m+1){
		ans+=n/t*flag;
		return;
	}
	dfs(dep+1,t,flag);
	dfs(dep+1,t/Gcd(t,a[dep])*a[dep],-flag);
}
int main(){
	n=read();
	m=read();
	rep(i,1,m)a[i]=read();
	dfs(1,1,1);
	cout<<ans<<endl;
	return 0;
}

信息

递交者
类型
递交
题目
计数 T1
题目数据
下载
语言
C++
递交时间
2017-10-07 14:13:32
评测时间
2017-10-07 14:13:32
评测机
分数
100
总耗时
128ms
峰值内存
456.0 KiB