题目
代码
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[100];
signed main(){
int n;
a[1]=2;
a[2]=5;
a[3]=11;
a[4]=13;
while(cin>>n){
int ans=n;
for(int i=1;i<(1<<4);i++){
int cnt=0,temp=1;
for(int j=0;j<4;j++){
if((1<<j)&i){
cnt++;
temp*=a[j+1];
}
}
// cout<<cnt<<" "<<temp<<endl;
if(cnt&1) ans-=n/temp;
else ans+=n/temp;
}
cout<<ans<<endl;
}
}

这是一个C++代码示例,用于计算输入数字n与一系列预设数的组合数,并根据组合数的奇偶性调整结果。程序通过位运算快速计算组合数,并输出最终的奇偶性总和。
348

被折叠的 条评论
为什么被折叠?



