A:模拟水题不说

#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <bitset> using namespace std;
typedef long long LL;
const int N= 1e3+;
char s[N][];
int main(){
int n;
scanf("%d",&n);
for(int i=;i<=n;++i)scanf("%s",s[i]+);
bool flag=false;
for(int i=;i<=n;++i){
if(s[i][]==s[i][]&&s[i][]=='O'){
flag=true;
s[i][]=s[i][]='+';
break;
}
if(s[i][]==s[i][]&&s[i][]=='O'){
flag=true;
s[i][]=s[i][]='+';
break;
}
}
if(flag)printf("YES\n");
else printf("NO\n");
if(flag)
for(int i=;i<=n;++i)printf("%s\n",s[i]+);
return ;
}

B:n*n的方阵,只有一个位置是未填数的,然后问填数以后,行和列和主副对角线和相等
     O(n^2)模拟即可(这题FST了,由于输出格式不太对,对了这个也许能上更多分吧)

#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <bitset> using namespace std;
typedef long long LL;
const int N= 5e2+;
LL a[N][N];
int main(){
int n,x,y;
scanf("%d",&n);
for(int i=;i<=n;++i){
for(int j=;j<=n;++j){
scanf("%I64d",&a[i][j]);
if(a[i][j]==){
x=i;
y=j;
}
}
}
if(n==){
printf("1\n");
return ;
}
LL sum=;
if(x==)
for(int i=;i<=n;++i)sum+=a[][i];
else
for(int i=;i<=n;++i)sum+=a[][i];
LL ret=-;
for(int i=;i<=n;++i){
LL tmp=;
for(int j=;j<=n;++j)
tmp+=a[i][j];
if(i==x){
if(tmp<sum){
if(ret!=-&&ret!=sum-tmp){
printf("-1\n");
return ;
}
else ret=sum-tmp;
}
else {
printf("-1\n");
return ;
}
}
else{
if(sum!=tmp){
printf("-1\n");
return ;
}
}
}
for(int j=;j<=n;++j){
LL tmp=;
for(int i=;i<=n;++i)
tmp+=a[i][j];
if(j==y){
if(tmp<sum){
if(ret!=-&&ret!=sum-tmp){
printf("-1\n");
return ;
}
else ret=sum-tmp;
}
else {
printf("-1\n");
return ;
}
}
else{
if(sum!=tmp){
printf("-1\n");
return ;
}
}
}
LL tmp=;
for(int i=;i<=n;++i)tmp+=a[i][i];
if(x==y){
if(tmp<sum){
if(ret!=-&&ret!=sum-tmp){
printf("-1\n");
return ;
}
else ret=sum-tmp;
}
else {
printf("-1\n");
return ;
}
}
else{
if(sum!=tmp){
printf("-1\n");
return ;
}
}
tmp=;
for(int i=;i<=n;++i)tmp+=a[i][n+-i];
if(x+y==n+){
if(tmp<sum){
if(ret!=-&&ret!=sum-tmp){
printf("-1\n");
return ;
}
else ret=sum-tmp;
}
else {
printf("-1\n");
return ;
}
}
else{
if(sum!=tmp){
printf("-1\n");
return ;
}
}
printf("%I64d\n",ret);
return ;
}

C:赛场上写了个裸的O(n^4)的dp,dp[i][j][k]代表当前是第i个数,这个数是j,分成k块的最小值
    由于是时限是2s,而且是CF评测机,不虚

#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <bitset> using namespace std;
typedef long long LL;
const int N= 1e2+;
LL dp[N][N][N];
LL p[N][N];
int a[N];
int main(){
int n,m,k;
scanf("%d%d%d",&n,&m,&k);
for(int i=;i<=n;++i)scanf("%d",&a[i]);
for(int i=;i<=n;++i){
for(int j=;j<=m;++j)
scanf("%I64d",&p[i][j]);
}
memset(dp,-,sizeof(dp));
if(a[]!=)dp[][a[]][]=;
else{
for(int i=;i<=m;++i)
dp[][i][]=p[][i];
}
for(int i=;i<=n;++i){
int lim=min(k,i);
if(a[i]!=){
for(int j=;j<=lim;++j){
for(int c=;c<=m;++c){
if(dp[i-][c][j-]!=-&&a[i]!=c){
if(dp[i][a[i]][j]==-)dp[i][a[i]][j]=dp[i-][c][j-];
else dp[i][a[i]][j]=min(dp[i][a[i]][j],dp[i-][c][j-]);
}
if(dp[i-][c][j]!=-&&a[i]==c)
if(dp[i][a[i]][j]==-)dp[i][a[i]][j]=dp[i-][c][j];
else dp[i][a[i]][j]=min(dp[i][a[i]][j],dp[i-][c][j]);
}
}
continue;
}
for(int x=;x<=m;++x){
for(int j=;j<=lim;++j){
for(int c=;c<=m;++c){
if(dp[i-][c][j-]!=-&&x!=c){
if(dp[i][x][j]==-)dp[i][x][j]=dp[i-][c][j-]+p[i][x];
else dp[i][x][j]=min(dp[i][x][j],dp[i-][c][j-]+p[i][x]);
}
if(dp[i-][c][j]!=-&&x==c)
if(dp[i][x][j]==-)dp[i][x][j]=dp[i-][c][j]+p[i][x];
else dp[i][x][j]=min(dp[i][x][j],dp[i-][c][j]+p[i][x]);
}
}
}
}
LL ret=-;
for(int i=;i<=m;++i)
if(dp[n][i][k]!=-){
if(ret==-)ret=dp[n][i][k];
else ret=min(ret,dp[n][i][k]);
}
printf("%I64d\n",ret);
return ;
}

D:这种题很常见,有向环套树,看每个环的反转方案,是2^k-2(k是边数,必须翻一个,不能全翻)
     剩下的树上的边翻不翻都可以是2^tot,tot代表树边,然后都乘起来即可

#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <bitset>
using namespace std;
typedef long long LL;
const int N = 2e5+;
const LL mod = 1e9+;
int to[N],n;
int vis[N];
LL qpow(LL x,LL y){
LL ret=;
while(y){
if(y&)ret=ret*x%mod;
y>>=;
x=x*x%mod;
}
return ret;
}
int main(){
scanf("%d",&n);
for(int i=;i<=n;++i)scanf("%d",&to[i]);
LL z=n,ret=;
for(int i=;i<=n;++i){
if(vis[i])continue;
int x=i;
while(!vis[x]){
vis[x]=i;
x=to[x];
}
if(vis[x]!=i)continue;
int t=x,cnt=;
do{
++cnt;
t=to[t];
}while(t!=x);
z-=cnt;
ret=1ll*ret*((qpow(,cnt)-+mod)%mod)%mod;
}
ret=ret*qpow(,z)%mod;
printf("%I64d\n",ret);
return ;
}

E:考虑正难则反,概率等于1-A(k,2^n)/2^(nk),然后发现最大公约数只能是2^i,约分即可

#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <bitset>
using namespace std;
typedef long long LL;
const int N = 2e5+;
const LL mod = 1e6+;
LL qpow(LL x,LL y){
LL ret=;
while(y){
if(y&)ret=ret*x%mod;
x=x*x%mod;y>>=;
}
return ret;
}
int main(){
LL n,k;
scanf("%I64d%I64d",&n,&k);
if(n<=&&k>1ll<<n){
printf("1 1\n");
return ;
}
LL num=;
for(LL i=k-;i;i>>=){
num+=i/;
}
LL b=,a=qpow(,n);
for(LL i=;i<=k-;++i){
LL tmp=(a-i+mod)%mod;
b=b*tmp%mod;
if(tmp==)break;
}
LL inv=qpow(qpow(,num),mod-);
a=qpow(a,k-);
a=a*inv%mod;
b=b*inv%mod;
b=(a-b+mod)%mod;
printf("%I64d %I64d\n",b,a);
return ;
}

Codeforces Round #369 (Div. 2) 套题的更多相关文章

  1. Codeforces Round #579 (Div. 3) 套题 题解

    A. Circle of Students      题目:https://codeforces.com/contest/1203/problem/A 题意:一堆人坐成一个环,问能否按逆时针或者顺时针 ...

  2. Codeforces Round #361 (Div. 2) 套题

    A - Mike and Cellphone 问有没有多解,每个点按照给出的序列用向量法跑一遍 #include<cstdio> #include<cstring> #incl ...

  3. Codeforces Round #367 (Div. 2) 套题

    吐槽:只能说是上分好场,可惜没打,唉 A:Beru-taxi (水题,取最小值) #include <cstdio> #include <cstring> #include & ...

  4. Codeforces Round #612 (Div. 2) 前四题题解

    这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...

  5. Codeforces Round #378 (Div. 2) D题(data structure)解题报告

    题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...

  6. Codeforces Round #713 (Div. 3)AB题

    Codeforces Round #713 (Div. 3) Editorial 记录一下自己写的前二题本人比较菜 A. Spy Detected! You are given an array a ...

  7. Codeforces Round #552 (Div. 3) A题

    题目网址:http://codeforces.com/contest/1154/problem/ 题目意思:就是给你四个数,这四个数是a+b,a+c,b+c,a+b+c,次序未知要反求出a,b,c,d ...

  8. Codeforces Round #412 Div. 2 补题 D. Dynamic Problem Scoring

    D. Dynamic Problem Scoring time limit per test 2 seconds memory limit per test 256 megabytes input s ...

  9. Codeforces Round #369 (Div. 2)---C - Coloring Trees (很妙的DP题)

    题目链接 http://codeforces.com/contest/711/problem/C Description ZS the Coder and Chris the Baboon has a ...

随机推荐

  1. Groovy常用语法汇总

    基本语法 1.Grovvy的注释分为//和/**/和java的一样. 2.Grovvy语法可以不已分号结尾. 3.单引号,里面的内容严格的对应java中的String,不对$符号进行转义. def s ...

  2. 在移动端H5开发中(关于安卓端position:fixed和position:absolute;和虚拟键盘冲突的问题,以及解决方案)

    一.在开发移动端webapp时,我们经常会遇到这样的问题,当我们需要在页面底部固定一个logo或者说明时,往往会采用position:fixed进行固定定位或者absolute定位到最底部 这是一个很 ...

  3. 51NOD 2368 珂朵莉的旅行

    >>这是原题传送门<< 答案参考来自 http://www.cnblogs.com/sugewud/p/9822933.html 思路:思维题OR规律题?个人没写出来,脑子里只 ...

  4. SPI与I2C

    spi的最快传输速率是20mhz,i2c的传输速率是400khz. 版权声明:本文为博主原创文章,未经博主允许不得转载.

  5. 【】node基础概念问题(转载)

    1.nodejs编写HelloWord,了解什么是nodejs,nodejs有什么特点   2.nodejs的模块怎么用,如何载入别的模块(require),如何给另一模块调用(module, mod ...

  6. Android Studio 使用图片

    首先将图片放在drawable下 然后: <ImageView android:layout_width="wrap_content" android:layout_heig ...

  7. NYOJ-58最少步数,广搜思想!

    最少步数 时间限制:3000 ms  |  内存限制:65535 KB 难度:4 ->   Link  <- 这个题深搜广搜都是可以的,迷宫已经给出了,就看怎么做了:一般起点终点确定用广搜 ...

  8. fzu 2113 数位dp

    #include<stdio.h> #include<string.h> #define N 20 #define ll __int64 ll dp[N][N];//最多记忆4 ...

  9. 【IntelliJ 】IntelliJ IDEA 15 创建maven项目

    说明 创建Maven项目的方式:手工创建 好处:参考IntelliJ IDEA 14 创建maven项目二(此文章描述了用此方式创建Maven项目的好处)及idea14使用maven创建web工程(此 ...

  10. [运维]ELK实现日志监控告警

    https://blog.csdn.net/yeweiouyang/article/details/54948846