# 【noip2018模拟赛0】解题报告

## 清新不毒瘤的模拟赛

Posted by yjjr's blog on October 21, 2018

# T1 yyy点餐

## code

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define mem(x,num) memset(x,num,sizeof x)
#define ll long long
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
ll f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
const ll mod=998244353;
int n;
ll sum1=1,sum2=0;
ll inv(ll a){return a==1?1:(ll)(mod-mod/a)*inv(mod%a)%mod;}
void C(ll n,ll m){
if(m<0||n<m)return;//if(m>n-m)m=n-m;
ll up=1,down=1;
rep(i,0,m-1){up=up*(n-i)%mod;down=down*(i+1)%mod;sum1+=up*inv(down)%mod;sum1%=mod;}
}
int main(){
freopen("T1.in","r",stdin);
freopen("T1.out","w",stdout);
C(n-1,n-1);//puts("R");
//cout<<sum1<<' '<<sum2<<endl;
cout<<1ll*sum1*sum2%mod<<endl;
return 0;
}


# T2 yyy送礼物

## 题意

$\sum_{i=1}^n n\%i$

## code

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
ll f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
const int maxn=1e7+6;
bool not_prime[maxn+6];
int prime[maxn],cnt=0;
ll sd[maxn+6],sp[maxn+6],pre[maxn+6];
void Pre(){
not_prime[1]=1;sd[1]=sp[1]=1;
rep(i,2,maxn){
if(!not_prime[i]){
prime[++cnt]=i;
sd[i]=sp[i]=i+1;
}
rep(j,1,cnt){
if(i*prime[j]>maxn)break;
not_prime[i*prime[j]]=1;
if(i%prime[j]==0){
sd[i*prime[j]]=sd[i]/sp[i]*(sp[i]*prime[j]+1);
sp[i*prime[j]]=sp[i]*prime[j]+1;
break;
}else{
sd[i*prime[j]]=sd[i]*sd[prime[j]];
sp[i*prime[j]]=prime[j]+1;
}
}
}
rep(i,1,maxn)pre[i]=pre[i-1]+sd[i];
}

int main()
{
freopen("T2.in","r",stdin);
freopen("T2.out","w",stdout);
Pre();
while(T--){
printf("%lld\n",x*x-pre[x]);
}
return 0;
}


# T3 yyy的迷失

## code

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
ll f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
const int maxn=3e3+6;
int Map[maxn][maxn]={0},x1,x2,y1,y2,k,n,m,T;
char ch;
void check(){
if(x1==x2){
if(y1<y2)rep(i,y1,y2)Map[x1][i]=1;
else rep(i,y2,y1)Map[x1][i]=2;
}
else if(y1==y2){
if(x1>x2)rep(i,x2,x1)Map[i][y1]=3;
else rep(i,x1,x2)Map[i][y1]=4;
}
}
int main()
{
freopen("T3.in","r",stdin);
freopen("T3.out","w",stdout);
rep(i,1,n){
check();
}
while(T--){
if(ch=='U')k=1;
if(ch=='D')k=2;
if(ch=='L')k=3;
if(ch=='R')k=4;
//	cout<<k<<"R\n";
rep(j,1,t){
if(Map[x][y]!=0)k=Map[x][y];
if(k==1)y++;
if(k==2)y--;
if(k==3)x--;
if(k==4)x++;
if(x>m){x--;break;}
else if(x<0){x++;break;}
else if(y>m){y--;break;}
else if(y<0){y++;break;}
}
printf("%d %d\n",x,y);
}
return 0;
}