Problem A 简单计数
https://ac.nowcoder.com/acm/contest/879/A
题意:
题解:矩阵快速幂+构造矩阵
C++版本一
/*
*@Author: STZG
*@Language: C++
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
Problem B 投硬币
https://ac.nowcoder.com/acm/contest/879/B
题意:
题解:乘法逆元+概率
C++版本一
/*
*@Author: STZG
*@Language: C++
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
Problem C 植树造林
https://ac.nowcoder.com/acm/contest/879/C
题意:
题解:数学+思维
C++版本一
/*
*@Author: STZG
*@Language: C++
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
Problem D 签到题I
https://ac.nowcoder.com/acm/contest/879/D
题意:
题解:排序
C++版本一
/*
*@Author: STZG
*@Language: C++
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
Problem E 等比数列三角形
https://ac.nowcoder.com/acm/contest/879/E
题意:
题解:
C++版本一
/*
*@Author: STZG
*@Language: C++
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
C++版本二
#include
using namespace std;
#define LL long long
#define endl '\n'
const int mod=1e9+7;
LL n;
double e=(1.0+sqrt(5.0))/2;
LL b[5000];
int main()
{
while(cin>>n){
LL ans=n;
int sqr=sqrt(n);
for(int i=2;i<=sqr;i++){
b[i]=i-(int)(i/e)-1;
}
for(int i=2;i<=sqr;i++){
for(int j=i*2;j<=sqr;j+=i){
b[j]-=b[i];
}
ans=(ans+(n/(i*i))*b[i])%mod;
}
cout<
Problem F 乐色王传奇
https://ac.nowcoder.com/acm/contest/879/F
题意:
题解:
C++版本一
/*
*@Author: STZG
*@Language: C++
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
Problem G many sum
https://ac.nowcoder.com/acm/contest/879/G
题意:
题解:朴素
C++版本一
#include
using namespace std;
const int maxn = 2e6 + 5;
int a1[maxn];
long long b[maxn];
int main()
{
int n,a,m;
cin >> n >> a >> m;
a1[1] = a;
for(int i = 2; i <= n;i++){
a1[i] = (a1[i - 1] + 7 * i) % m;
}
for(int i = 1; i <= n;i++){
for(int j = i; j <= n; j+=i){
b[j]=b[j]+a1[i];
}
}
long long ans = 0;
for(int i = 1; i <= n;i++){
ans^=b[i];
}
cout << ans << endl;
}
Problem H 图上计数
https://ac.nowcoder.com/acm/contest/879/H
题意:
题解:
C++版本一
Problem I 有毒的玻璃球
https://ac.nowcoder.com/acm/contest/879/I
题意:
题解:积性函数+快速幂
C++版本一
/*
*@Author: STZG
*@Language: C++
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
Problem J J.I
https://ac.nowcoder.com/acm/contest/879/J
题意:
题解:
C++版本一