目录
| A | B | C | D | E | F |
|---|---|---|---|---|---|
| √ | √ | √ | √ | ○ | ○ |
( √:做出; ●:尝试未做出; ○:已补题 )
题目地址:https://atcoder.jp/contests/aising2020
A Number of Multiples
题意:签到题
思路:
代码:
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> P;
int read()
{
int x=0,flag=1;
char c=getchar();
while((c>'9' || c<'0') && c!='-') c=getchar();
if(c=='-') flag=0,c=getchar();
while(c<='9' && c>='0') {
x=(x<<3)+(x<<1)+c-'0';c=getchar();}
return flag?x:-x;
}
int main()
{
int L=read(),R=read(),d=read();
int ans=0;
REP(i,L,R) if(i%d==0) ans++;
cout<<ans;
return 0;
}
B An Odd Problem
题意:签到题
思路:
代码:
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> P;
int read()
{
int x=0,flag=1;
char c=getchar();
while((c>'9' || c<'0') && c!='-') c=getchar();
if(c=='-') flag=0,c=getchar();
while(c<='9' && c>='0') {
x=(x<<3)+(x<<1)+c-'0';c=getchar();}
return flag?x:-x;
}
int main()
{
int ans=0,n=read();
REP(i,1,n)
{
int x=read();
if(i&1 && x&1) ans++;
}
cout<<ans;
return 0;
}
C XYZ Triplets
题意: f ( n ) f(n) f(n) 表示满足以下条件的三元组 ( x , y , z ) (x,y,z) (x,y,z) 的个数:
- 1 ≤ x , y , z 1\le x,y,z 1≤x,y,z
- x 2 + y 2 + z 2 + x y + y z + z x = n x^2+y^2+z^2+xy+yz+zx=n x2+y2+z2+xy+yz+zx=n
给出 N( 1 ≤ N ≤ 1 0 4 1\le N\le 10^4 1≤N≤104),输出 f ( 1 ) , f ( 2 ) , . . . , f ( N ) f(1),f(2),...,f(N) f(1),f(2),...,f(N) 。
思路:根据 N 的范围可以推断出,xyz都不超过100,所以就三重循环更新 f 数组就行了。
代码:
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> P;
int read()
{
int x=0,flag=1;
char c=getchar();
while((c>'9' || c<'0') && c!='-') c=getchar();
if(c=='-') flag=0,c=getchar();
while(c<='9' && c>='0') {
x=(x<<3)+(x<<1)+c-'0';c=getchar();}
return flag?x:-x;
}
int f[10005];
int main()
{
REP(i,1,100) REP(j,1,100) REP(k,1,100)
{
int x=i*i+j*j+k*k+i*j+i*k+j*k;
if(x<=10000) f[x]++;
}
int N=read();
REP(i,1,N) printf("%d\n",f[i]);
return 0;
}
D Anything Goes to Zero
题意: f ( n ) f(n) f(n) 表示把一个非负整数 n 经过若干次这样的操作——把 n 替换成 n m o d p o p c o u n t ( n ) n \ mod \ popcount(n) n mod popcount(n) ——最后变成 0 所需要操作的次数。现在给出有 N( 1 ≤ N ≤ 2 × 1 0 5 1\le N\le 2\times10^5 1≤N≤2×10

本文深入解析AtCoder平台上的六道编程挑战题目,涵盖数学运算、组合计数、动态规划、优先队列等算法技巧,提供了详细的解题思路及代码实现。
最低0.47元/天 解锁文章
574

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



