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. LogStash plugins-inputs-file介绍(三)

    官方文档 https://www.elastic.co/guide/en/logstash/current/plugins-inputs-file.html 重要参数: path # 文件路径 sin ...

  2. thinkphp图像的裁剪、缩放、加水印

    ThinkPHP 图片处理函数,需要文字水印字体,可在windows下 控制面板 > 大图标(右上角) > 字体 找到需要的字体 1 2 3 4 5 6 7 8 9 10 11 12 13 ...

  3. Wannafly挑战赛9 D - 造一造

    链接:https://www.nowcoder.com/acm/contest/71/D来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言52428 ...

  4. HDU Today hdu 2112

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=2112 文章末有一些相应的测试数据供参考. 此题就是一个求最短路的问题,只不过现在的顶点名称变成了字符串而不 ...

  5. CodeForces1082G Petya and Graph 最小割

    网络流裸题 \(s\)向点连边\((s, i, a[i])\) 给每个边建一个点 边\((u, v, w)\)抽象成\((u, E, inf)\)和\((v, E, inf)\)以及边\((E, t, ...

  6. 20162325 金立清 S2 W11 C20

    20162325 2017-2018-2 <程序设计与数据结构>第11周学习总结 教材关键概念摘要 在哈希方法中,元素保存在哈希表中,其在表中的位置由哈希函数确定. 两个元素或关键字映射到 ...

  7. Android中Service与IntentService的使用比较

    不知道大家有没有和我一样,以前做项目或者练习的时候一直都是用Service来处理后台耗时操作,却很少注意到还有个IntentService,前段时间准备面试的时候看到了一篇关于IntentServic ...

  8. ZOJ 2969 Easy Task

    E - Easy Task Description Calculating the derivation of a polynomial is an easy task. Given a functi ...

  9. vue 组件开发 props 验证

    使用props 在Vue中父组件向子组件中传送数据是通过props实现的,一个简单的使用props的例子: <!DOCTYPE html> <html> <head> ...

  10. 使用Chrome快速实现数据的抓取(五)—— puppeteer

    如果要以自动化的方式驱动Chrome进行数据抓取,必须实现Chrome Dev Protocol协议的客户端.这个协议本身并不复杂,我在之前的文章中也简单的介绍过一下. Google本身有一个Node ...