# C. Game with Chips

## 题意

LRUD对应移动的方向，输出构造的路径。

## 思路

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

ll n,m,k;

int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m>>k;
for(int i=1;i<=2*k;i++){
int x,y;
cin>>x>>y;
}
cout<<n*(m-1)+2*n+m-3<<'\n';
for(int i=1;i<=m-1;i++){
cout<<'L';
}
for(int i=1;i<=n-1;i++){
cout<<'U';
}
for(int i=1;i<=n;i++){
if(i>1) cout<<'D';
for(int j=1;j<=m-1;j++) cout<<((i%2==1)?'R':'L');
}
return 0;
}


# E. Count The Blocks

## 思路

$f[n]=n*10^n-sum[n-1]-(a[1]*10^{n-1}+a[2]*10^{n-2}+...+a[n-1]*10^1)$
$sum[n]=sum[n-1]+f[n]$


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 998244353;
const ll  maxn = 1e6 + 5;

ll ans[maxn],s[maxn],a[maxn];

int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n;
a[0]=1;
for(int i=1;i<=n;i++) a[i]=(a[i-1]*10)%mod;
ll res=0,k=0;
for(int i=1;i<=n;i++){
ans[i]=(i*a[i]-s[i-1]-k+2*mod)%mod;
s[i]=(s[i-1]+ans[i])%mod;
k=(k+s[i])%mod;
}
for(int i=n;i>=1;i--){
cout<<ans[i]<<" ";
}
return 0;
}


©️2019 CSDN 皮肤主题: 书香水墨 设计师: CSDN官方博客