9.11总结
成绩
| 「MSOI R1」回响 | [ECNA 2024] Oooh I See | [PacNW 2025] Training, Round 4 | [入门赛 #50] 数论对称差 | [ICPC 2017 Hong Kong R] Card collection | 得分 | 排名 |
|---|---|---|---|---|---|---|
| 100 | 100 | 0 | 0 | 0 | 200 | 6 |
[PacNW 2025] Training
错误代码
无
错误思路
无
正确思路
维护 (两⽅向已达标⾼度)、(剩余免费升级数)、 (初始等级和),初 值取第 题的两个难度且 ;⾃第 题起逐题处理:若新难度⾼于对应前缀最⼤值,先⽤ 池⼦补⻬,补不上的部分累⼊ ;本题处理完后 。
正确代码
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,c[55],t[55],ans,a,b,cnt=1;
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)cin>>c[i]>>t[i];
a=c[1],b=t[1];
ans=a+b;
for(int i=2;i<=n;i++){
if(c[i]>a)
{
if(c[i]-a<=cnt)cnt-=(c[i]-a),a=c[i];
else a+=cnt,cnt=0,ans+=c[i]-a,a=c[i];
}
if(t[i]>b){
if(t[i]-b<=cnt)cnt-=(t[i]-b),b=t[i];
else b+=cnt,cnt=0,ans+=t[i]-b,b=t[i];
}
cnt++;
}
cout<<ans;
return 0;
}[入门赛 #50] 数论对称差
错误代码
#include<bits/stdc++.h>
using namespace std;
int T;
void solve()
{
int n,m,f=0;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(n%i==0 and n%j!=0 and m%i!=0 and m%j==0 and f==0)
{
cout<<i*j<<'\n';
f=1;
}
}
if(f==1)
{
break;
}
}
if(f==0)
{
cout<<1<<'\n';
}
}
int main()
{
cin>>T;
while(T--)
{
solve();
}
return 0;
}
错误思路
想了一下,只能暴力
正确思路
预处理出 每组查询令输出。
正确代码
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e7+10;
int cnt[N],vis[N];
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
for(int i=1;i<=1e7;i++)
{
cnt[i]=1;
}
for(int i=2;i<=1e7;i++)
{
if(vis[i]==0)
{
for(int j=i;j<=1e7;j+=i)
{
vis[j]=1;
cnt[j]*=i;
}
}
}
int t;
cin>>t;
while(t--)
{
int x,y;
cin>>x>>y;
x=cnt[x];
y=cnt[y];
cout<<x*y/__gcd(x,y)/__gcd(x,y)<<'\n';
}
return 0;
}