【MS编程之美资格赛】Problem A及Problem B
来源:互联网 发布:iptv与网络电视的区别 编辑:程序博客网 时间:2024/05/16 13:51
题目链接:点击打开链接
第一题和第二题都是小数据和大数据都AC了,65分。。略高兴
思路请看各位大神的博客吧。。他们写的比我好
A:
#include <iostream>#include <string>#include <map>#include <stdio.h>using namespace std;map<string,string> tp;int main(){int testcase;cin>>testcase;for(int a=1;a<=testcase;a++){tp.clear();string tar[300];int player,wordlen;string t1,t2;cin>>player>>wordlen;for(int i=0;i<wordlen;i++){cin>>t1>>t2;tp.insert(make_pair(t1,t2));}int t=0;char p;while(1){cin>>tar[t];t++;p=getchar();if(p=='\n')break;}map<string,string>::iterator it;for(int i=1;i<player;i++){for(int j=0;j<t;j++){it=tp.find(tar[j]);if(it!=tp.end()){tar[j]=it->second;}}}cout<<"Case #"<<a<<": ";for(int i=0;i<t;i++){if(i!=t-1)cout<<tar[i]<<" ";elsecout<<tar[i]<<endl;}}return 0;}B:
#include <stdio.h> #include <iostream> #include <string.h> #include <math.h> using namespace std; int n,m,k; void swap(long long &a,long long &b) { long long t=a; a=b; b=t; } long long getc(long long j) { return j*(j-1)/2; } int main() { int testcase; int p=1;cin>>testcase; while (testcase--) { scanf("%d%d%d",&n,&m,&k); if (n<m) swap(n,m); int t=sqrt(k); int b=t>m?m:t; int a=k/b>n?n:k/b; long long max=0; for (;b>=2 && a<=n;--b,a=k/b) { long long sum=getc(a)*getc(b); int p=k-a*b; if (a<n) { sum=sum+getc(p)*a; } else { sum=sum+getc(p)*b; } max=max>sum?max:sum; } cout<<"Case #"<<p<<": "<<max<<endl; p++; } return 0; }
- 【MS编程之美资格赛】Problem A及Problem B
- 2016百度之星资格赛 Problem B
- 百度之星-资格赛Problem B
- 2016"百度之星" - 资格赛 Problem B
- 2016"百度之星" - 资格赛 Problem A
- 百度之星 2016资格赛 Problem A
- 2016百度之星资格赛 Problem A
- 2015编程之美资格赛B
- [编程之美]资格赛 B Palindrome
- 2015编程之美资格赛A
- 2016"百度之星" - 资格赛(Astar Round1)Problem A B C D--java代码
- 2016"百度之星" - 资格赛(Astar Round1)Problem B
- 2016"百度之星" - 资格赛(Astar Round1)Problem B
- Problem B 2016"百度之星" - 资格赛(Astar Round1)
- 2016-百度之星-资格赛-Problem B【高精度】
- HDU 5686:2016"百度之星" - 资格赛 Problem B
- 编程之美资格赛
- 编程之美资格赛
- HDU 1011 Starship Troopers - 01树形dp 有坑啊!!
- SQL中的循环、for循环、游标
- 使用响应流来输出文件(适合导出文件使用,本文主要测试的是导出excel)
- spring MVC入门
- 【COCOS2DX-LUA 脚本开发之七】解决( error in function ‘addChild’. argument #2 is ‘xx’; ‘CCNode’ expected. )异常报错
- 【MS编程之美资格赛】Problem A及Problem B
- A+B
- VirtualBox报“uuid already exists”错误
- app store 申请
- MyBatis源码赏析3-配置
- Webservice使用
- Manually install DB2 on Linux
- 第四次上机实验
- Android——在已有布局中动态添加控件