二中3月31日noip原题模拟赛
3月31日NOIP原题祭
score: 250/400
模拟水题 回文日期
考试时垃圾做法
#include <bits/stdc++.h>
using namespace std;
int d1,d2,ans,lim1=12,lim2;
int y2,m2,r2;
int y,m,r;
int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
void init(){
r=d1%100; d1/=100;
m=d1%100; d1/=100;
y=d1;
r2=d2%100; d2/=100;
m2=d2%100; d2/=100;
y2=d2;
}
bool check(int b){
if(b%400==0 || (b%4==0 && b%100!=0))
return true;
return false;
}
bool check2(int Y,int M,int D){
int tmp=D%10*1000+D/10*100+M%10*10+M/10;
if(Y==tmp) return true;
return false;
}
int main(){
freopen("date.in","r",stdin);
freopen("date.out","w",stdout);
scanf("%d",&d1);
scanf("%d",&d2);
init();
while(y<=y2){
if(check(y)) a[2]=29;
else a[2]=28;
if(y==y2) lim1=m2;
if(y==y2 && m==lim1) lim2=r2;
else lim2=a[m];
if(r>lim2){
if(y==y2&&m==m2) break;
r=1,m++;
}
if(m>lim1){
if(y==y2) break;
m=1,y++;
}
if(check2(y,m,r)) ans++;
r++;
}
cout << ans << endl;
return 0;
}
模拟水题 潜伏者
#include <bits/stdc++.h>
using namespace std;
const int N=30;
bool islock[N],istrans[N],fail;
int trans[N],sum;
string a,b,c;
int main(){
freopen("spy.in","r",stdin);
freopen("spy.out","w",stdout);
cin >> a >> b >> c;
int len=a.size();
for(int i=0;i<len;i++){
int l1=a[i]-'A'+1,l2=b[i]-'A'+1;
if(!islock[l1] && !istrans[l2]){
trans[l1]=l2; sum++;
islock[l1]=true;
istrans[l2]=true;
}
else if(trans[l1]!=l2){
fail=true; break;
}
}
if(sum!=26) fail=true;
if(fail)
puts("Failed");
else{
len=c.size();
for(int i=0;i<len;i++){
int l=c[i]-'A'+1;
cout << char(trans[l]-1+'A');
}
cout << endl;
}
return 0;
}
蓝题 解方程
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int P=1e9+7;
const int mp=99991;
const int N=105;
const int M=1e6+20;
int n,m,a[N],b[N],cnt,ans[M];
bool flag[M];
void read(int i){
ll x1=0,x2=0,f=1; char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch)){x1=(x1*10+ch-'0')%mp;
x2=(x2*10+ch-'0')%P;ch=getchar();}
a[i]=x1*f; b[i]=x2*f;
}
bool check(ll x){
ll sum=0;
for(int i=n;i>=1;i--){
sum=((sum+a[i])*x)%mp;
}
sum=(sum+a[0])%mp;
return !sum;
}
bool check2(ll x){
ll sum=0;
for(int i=n;i>=1;i--){
sum=((sum+b[i])*x)%P;
}
sum=(sum+b[0])%P;
return !sum;
}
int main(){
freopen("equation.in","r",stdin);
freopen("equation.out","w",stdout);
double cl=clock();
scanf("%d%d",&n,&m);
for(int i=0;i<=n;i++){
read(i);
}
for(int i=1;i<=mp;i++){
if(check(i)){
for(int j=i;j<=m;j+=mp)
if(check2(j)) flag[j]=true;
}
}
for(int i=1;i<=m;i++)
if(flag[i]) ans[++cnt]=i;
cout << cnt << endl;
for(int i=1;i<=cnt;i++)
cout << ans[i] << endl;
cout << clock()-cl << endl;
return 0;
}