S组-程皓楠-第六场考试总结
Crash_Man_CHN · · 个人记录
前言
我的208分!!!!!!!!!!!,直接挂掉了200分!!!!!!!!!!!!!!!!!!!!!
T1
考场代码
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+5;
int f[N][25];
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int c,n;
cin>>c>>n;
if(c>n)
{
cout<<-1;
return 0;
}
if(n/c==0)
{
cout<<-1;
return 0;
}
if(n/c==1)cout<<c*c;
else cout<<(c*c)*(n/c)*(n/c-1);
return 0;
}
错误点
const int N=1e6+5;
int f[N][25];
数组空间炸了,原因是考试从暴力改成正解的过程忘记删了,痛失100pts
正确代码
#include <bits/stdc++.h>
#define int long long
using namespace std;
// const int N=1e6+5;
// int f[N][25];
// 就是这里!!!
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int c,n;
cin>>c>>n;
if(c>n)
{
cout<<-1;
return 0;
}
if(n/c==0)
{
cout<<-1;
return 0;
}
if(n/c==1)cout<<c*c;
else cout<<(c*c)*(n/c)*(n/c-1);
return 0;
}
T2
考场代码
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
string s;
cin>>s;
int n=s.size();
if(n<3)
{
cout<<0;
return 0;
}
int ans=0,tot=0;
for(int i=n-1;i>=0;i--)
{
if(i<n-1&&s[i]=='B'&&s[i+1]=='C')tot++;
else if(s[i]=='A')ans+=tot;
else tot=0;
}
cout<<ans;
return 0;
}
错误点
错误出现在
for(int i=n-1;i>=0;i--)
痛失100pts
正确代码
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
string s;
cin>>s;
int n=s.size();
if(n<3)
{
cout<<0;
return 0;
}
int ans=0,tot=0;
for(int i=0;i<n;i++)
{
if(i<n-1&&s[i]=='B'&&s[i+1]=='C')ans+=tot,i++;
else if(s[i]=='B'&&(!(s[i+1]=='C'||i<n-1)))tot=0;
else if(s[i]=='A')tot++;
else tot=0;
}
cout<<ans;
return 0;
}
T3
我想的是40分思路,但是只拿到了8pts,结果听完老师讲解,发现和正解差不多,那我还想40pts干嘛,就是把我的考场代码的两个函数合并,然后循环改一下,但是有个地方就是当b>1000000,x最多只有三位,所以我们可以枚举到999,所以这样就AC了
正确代码
#include <bits/stdc++.h>
#define int long long
using namespace std;
int check(int x,int k)
{
int now=0,temp=1;
while(x)
{
if(x%k>=10)return -1;
now+=temp*(x%k);
x/=k;
temp*=10;
}
return now;
}
int js(int x,int k)
{
return x%10+(x/10%10)*k+(x/100)*k*k;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int y,l,ans=0;
cin>>y>>l;
for(int i=l;i<=999;i++)
{
int l=1e6-1,r=1e18+1;
if(i>=100)r=1e9+1;
while(l+1<r)
{
int mid=(l+r)/2;
if(js(i,mid)>=y)r=mid;
else l=mid;
}
if(js(i,r)==y)ans=max(ans,r);
}
for(int i=1000000;i>=ans;i--)
{
if(check(y,i)>=l)
{
ans=i;
break;
}
}
cout<<ans;
return 0;
}