o(︶︿︶)o 唉跪烂了……

B题由于考虑的不周全WA了3次……

C题由于#include了<cmath>,而我函数声明的是pow(LL a,LL b)但调用的时候 【没!有!把!n!的!数据类型!!改成!long long !!!】所以触发了自动类型转换……就调用成cmath库里的了!!!

教训:

  以后自己写函数名的时候尽量避开pow等敏感词(NOIP时候的pipe事件……)可以首字母大写,或者改个名字比如pow_mod


A:

  统计题……考你会不会C++(或其他语言……)

  统计一下是否26个英文字母都出现了即可,大小写均可。(妈蛋考试的时候Dev-C++突然崩溃了,害我还得重启电脑,没本机跑过一遍不敢交啊……万一CE就是50分QAQ)

 //CF #295 div.2 A
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;++i)
#define F(i,j,n) for(int i=j;i<=n;++i)
#define D(i,j,n) for(int i=j;i>=n;--i)
using namespace std;
int getint(){
int v=,sign=; char ch=getchar();
while(!isdigit(ch)) {if(ch=='-') sign=-; ch=getchar();}
while(isdigit(ch)) {v=v*+ch-''; ch=getchar();}
return v*sign;
}
const double eps=1e-;
typedef long long LL;
/*******************template********************/
bool a[];
char s[]; int main(){ int n=getint();
scanf("%s",s);
rep(i,n)
if (s[i]>='A' && s[i]<='Z') a[s[i]-'A']=;
else a[s[i]-'a']=;
bool sign=;
rep(i,)
if (!a[i]) sign=;
puts(sign ? "YES" : "NO");
return ;
}

B:

  1.当n>=m时明显*2是无意义的……ans=n-m;

  2.当n<m时,一个简单的过程是这样的:n不断翻倍直到n>=m,然后再不断-1直到n==m; 即 $ n*2^{t_1}-1*{t_3} $

  那么怎样操作数就减少了呢?在不断$*2$的过程中插入-1操作!也就是说我们的操作可以写成: $ n*2*2\cdots *2 $ 然后又在中间某些位置插入了-1!

  那么我们乘法分配律展开一下就变成了 \[ n*2^{t_1} -1*2^{x_1}-1*2^{x_2}-\dots-1*2^{x_n}  (其中2^{x_1}+2^{x_2}+ \dots +2^{x_n}=t_3) \]

  看上去好像只要将t3进行二进制拆分,相对应的就是一种合法方案了。真的是这样吗?当t3比较大、而t1比较小的时候呢?$2^{x1}$这项前面的系数就不一定是-1了!因为没有更高位可以进位了!

  所以应该是用除法!再取余来分解!

 //CF #295 div.2 B
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;++i)
#define F(i,j,n) for(int i=j;i<=n;++i)
#define D(i,j,n) for(int i=j;i>=n;--i)
#define pb push_back
using namespace std;
int getint(){
int v=,sign=; char ch=getchar();
while(!isdigit(ch)) {if(ch=='-') sign=-; ch=getchar();}
while(isdigit(ch)) {v=v*+ch-''; ch=getchar();}
return v*sign;
}
const int N=1e7+,INF=~0u>>;
const double eps=1e-;
typedef long long LL;
/*******************template********************/
int n,m,ans;
int main(){
n=getint();
m=getint();
ans=;
if (m<=n) ans=n-m;
else {
int t1=;
for(;n<m;n<<=,t1++);
int t2=n-m,t3=;
F(i,,t1) t3<<=;
while(t2){
t1+=t2/t3;
t2%=t3;
t3>>=;
}
ans=t1;
}
printf("%d\n",ans);
return ;
}

C:

  sigh……其实是个傻逼题,我被吓到了所以没敢上手……读懂题目意思后很快就解出来了。

  从题目描述中给出的样例可以发现:字符串 s 的每一位都要和字符串 t 的每一位匹配 n 次!也就是说其实每一位是单独考虑的……这一位对那个函数 $ \rho(s,t) $ 的贡献取决于这个字符与原串有多少可以匹配的节点!即它与多少位置的字符相同!显而易见如果要找$\rho$最大的,明显需要让 t 中的字符是 s 中出现次数最多的那个,如果有多个最大值(比如A和G都是出现次数最多的),那每一位都会有两种选择,所以总方案数就是 $x^n\mod P$ 其中x为出现次数最多的字符的种数,n为读入的字符串的长度。

 //CF #295 div.2 C
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;++i)
#define F(i,j,n) for(int i=j;i<=n;++i)
#define D(i,j,n) for(int i=j;i>=n;--i)
#define pb push_back
using namespace std;
const int N=1e7+,INF=~0u>>;
const double eps=1e-;
typedef long long LL;
/*******************template********************/
const int P=+;
char s[];
int cnt[];
LL pow(LL a,LL b){
LL r=,base=a;
while(b){
if (b&) r=r*base%P;
base=base*base%P;
b>>=;
}
return r;
}
int main(){
int n;
cin >>n;
scanf("%s",s);
memset(cnt,,sizeof cnt);
rep(i,n){
if (s[i]=='A') cnt[]++;
if (s[i]=='T') cnt[]++;
if (s[i]=='C') cnt[]++;
if (s[i]=='G') cnt[]++;
}
LL max=-,ans=-;
F(i,,){
if (cnt[i]==max) ans++;
else if (cnt[i]>max){ max=cnt[i]; ans=;}
}
LL A=pow(ans,n);
cout << A <<endl;
return ;
}

【Codeforces】【#295】【Div.2】的更多相关文章

  1. 【Codeforces 851D Arpa and a list of numbers】

    Arpa的数列要根据GCD变成好数列. ·英文题,述大意:      给出一个长度为n(n<=5000000)的序列,其中的元素a[i]<=106,然后输入两个数x,y(x,y<=1 ...

  2. 【Codeforces】Round #491 (Div. 2) 总结

    [Codeforces]Round #491 (Div. 2) 总结 这次尴尬了,D题fst,E没有做出来.... 不过还好,rating只掉了30,总体来说比较不稳,下次加油 A:If at fir ...

  3. 【Codeforces】Round #488 (Div. 2) 总结

    [Codeforces]Round #488 (Div. 2) 总结 比较僵硬的一场,还是手速不够,但是作为正式成为竞赛生的第一场比赛还是比较圆满的,起码没有FST,A掉ABCD,总排82,怒涨rat ...

  4. Codeforces Round #433 (Div. 2)【A、B、C、D题】

    题目链接:Codeforces Round #433 (Div. 2) codeforces 854 A. Fraction[水] 题意:已知分子与分母的和,求分子小于分母的 最大的最简分数. #in ...

  5. 【codeforces】【比赛题解】#960 CF Round #474 (Div. 1 + Div. 2, combined)

    终于打了一场CF,不知道为什么我会去打00:05的CF比赛…… 不管怎么样,这次打的很好!拿到了Div. 2选手中的第一名,成功上紫! 以后还要再接再厉! [A]Check the string 题意 ...

  6. 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory

    [题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...

  7. 【Codeforces Round #421 (Div. 2) A】Mister B and Book Reading

    [题目链接]:http://codeforces.com/contest/820/problem/A [题意] 每天看书能看v页; 且这个v每天能增加a; 但是v有上限v1; 然后每天还必须往回看t页 ...

  8. 【Codeforces Round #427 (Div. 2) A】Key races

    [Link]:http://codeforces.com/contest/835/problem/A [Description] [Solution] 傻逼题. [NumberOf WA] [Revi ...

  9. 【Codeforces Round #428 (Div. 2) A】Arya and Bran

    [Link]: [Description] [Solution] 傻逼题 [NumberOf WA] [Reviw] [Code] #include <bits/stdc++.h> usi ...

  10. 【Codeforces Round #445 (Div. 2) B】Vlad and Cafes

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 傻逼模拟 [代码] #include <bits/stdc++.h> using namespace std; cons ...

随机推荐

  1. linux kernel.shmall shemax shemin解释

        Linux X86-64操作系统,Oracle 10g数据库,由8G加到16G,把kernel.shmmax参数改到17179869184(16G)后,发现只要修改sga_max_size和s ...

  2. Ionic Js二:背景层

    我们经常需要在 UI 上,例如在弹出框.加载框.其他弹出层中显示或隐藏背景层. 在组件中可以使用\(ionicBackdrop.retain()来显示背景层,使用\)ionicBackdrop.rel ...

  3. Redis的安装与部署(CentOS6.5)

    一.下载安装包 wget http://redis.googlecode.com/files/redis-2.4.5.tar.gz 二.编译源程序 tar -zxvf redis-2.4.5.tar. ...

  4. 牛客练习赛1 B - 树

    链接:https://www.nowcoder.com/acm/contest/2/B来源:牛客网 题目描述 shy有一颗树,树有n个结点.有k种不同颜色的染料给树染色.一个染色方案是合法的,当且仅当 ...

  5. 洛谷P3527 [POI2011]MET-Meteors [整体二分]

    题目传送门 Meteors 格式难调,题面就不妨放了. 分析: 一道整体二分的练手题. 就是一般的整体二分的套路,但是要注意,将修改和询问加入队列的时候要先加修改再加询问.另外,博主代码打得太丑,常数 ...

  6. springboot+thymeleaf 模板中传递参数误报错误 红色波浪线

    在使用IDEA开发SpringBoot项目时,使用了Thymeleaf模板引擎,在使用动态传参数时,HTML页面的动态参数出现了红色波浪线,情况如下如: 解决办法: 选择 File -> Set ...

  7. 说一说Servlet的生命周期

    servlet有良好的生存期的定义,包括加载和实例化.初始化.处理请求以及服务结束.这个生存期由javax.servlet.Servlet接口的init,service和destroy方法表达. Se ...

  8. [leetcode DP]63. Unique Paths II

    Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How m ...

  9. SQL语句之 知识补充

    SQL语句之 知识补充 一.存储过程 运用SQL语句,写出一个像函数的模块,这就是存储过程. 需求: 编写存储过程,查询所有员工 -- 创建存储过程(必须要指定结束符号) -- 定义结束符号 DELI ...

  10. golang实现base64编解码

    golang中base64的编码和解码可以用内置库encoding/base64 package main import ( "encoding/base64" "fmt ...