USACO Section 1.1
这是4道大水题。
因为我看有些题解写的很丑陋,就把我的代码发上来。
第一题是我早期作品,丑陋不堪......
#include <cstdio>
#include <iostream>
using namespace std; char a[];
char b[]; int pan(char c)
{
if(c=='B') return ;
if(c=='C') return ;
if(c=='D') return ;
if(c=='E') return ;
if(c=='F') return ;
if(c=='G') return ;
if(c=='H') return ;
if(c=='I') return ;
if(c=='J') return ;
if(c=='K') return ;
if(c=='L') return ;
if(c=='M') return ;
if(c=='N') return ;
if(c=='O') return ;
if(c=='P') return ;
if(c=='Q') return ;
if(c=='R') return ;
if(c=='S') return ;
if(c=='T') return ;
if(c=='U') return ;
if(c=='V') return ;
if(c=='W') return ;
if(c=='X') return ;
if(c=='Y') return ;
if(c=='Z') return ;
return ;
} int xiuxi1()
{
int s=;
for(int i=;i<=;i++)
{
s*=pan(a[i]);
s%=;
}
return s;
} int xiuxi2()
{
int s=;
for(int i=;i<=;i++)
{
s*=pan(b[i]);
s%=;
}
return s; } int main()
{
cin>>a;
cin>>b;
//printf("xiuxi1:%d xiuxi2:%d\n",xiuxi1(),xiuxi2());
if(xiuxi1()==xiuxi2())
{
printf("GO");
return ;
}
printf("STAY");
return ;
}
P1200 代码在此
好,下三题是我最近作品,欣赏较为成型的代码风格吧。
#include <cstdio>
#include <iostream>
using namespace std;
string name[];
int n;
int findNum(string a)
{
for(int i=;i<=n;i++) if(name[i]==a) return i;
printf("-1\n");
return -;
}
int get[];
int main()
{
scanf ("%d",&n);
for(int i=;i<=n;i++) cin>>name[i];
for(int i=;i<=n;i++)
{
string c;
cin>>c;
int now=findNum(c),man,money;
scanf("%d%d",&money,&man);
get[now]-=money;
if(man)get[now]+=money-(money/man)*man;
//if(man){cout<<name[now];printf(" +%d\n",money-(money/man)*man);}
if(man)money/=man;
for(int j=;j<=man;j++)
{
cin>>c;
get[findNum(c)]+=money;
//cout<<c<<'+'<<money<<endl;
}
}
for(int i=;i<=n;i++) cout<<name[i]<<" "<<get[i]<<endl;
return ;
}
P1201
#include <cstdio>
using namespace std; int month[]={,,,,,,,,,,,,};
int week[],now=;
bool is_run_year(int a)
{
if(a%==) return ;
if(a%==) return ;
if(a%==) return ;
return ;
}
int main()
{
int n;
scanf ("%d",&n);
int y=,m=,d=;
for(;y<+n;d++,now++)
{
if(is_run_year(y)) month[]=;
else month[]=;
if(d>month[m]) d=,m++;
if(m>) m=,y++;
if(now>) now=;
if(d==)
{
//printf("%d.%d.%d is %d\n",y,m,d,now);
week[now]++;
}
}
printf("%d %d %d %d %d %d %d",week[],week[],week[],week[],week[],week[],week[]);
return ;
}
P1202
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n;
char c[];
int find_sum(int p,int k)
{
int ans=;
char flag=c[p];int pp=p;
while(flag=='w' && pp> && pp<*n+)
{
pp+=k;
flag=c[pp];
}
while(p> && p<*n+)
{
if(c[p]==flag || c[p]=='w') ans++;
else break;
p+=k;
}
return ans;
}
int main()
{
scanf ("%d",&n); cin>>c+;
for(int i=;i<=n;i++)
{
c[i+n]=c[i];
}
int ans=;
for(int i=;i<=n*;i++)
{
int now=find_sum(i,-)+find_sum(i+,);
//printf("%d now = %d\n",i,now);
ans=max(ans,now);
}
//printf("%d\n",ans);
printf("%d",min(ans,n));
return ;
}
P1203
以后写工程肯定不止这样......
USACO Section 1.1的更多相关文章
- USACO Section 1.3 题解 (洛谷OJ P1209 P1444 P3650 P2693)
usaco ch1.4 sort(d , d + c, [](int a, int b) -> bool { return a > b; }); 生成与过滤 generator&& ...
- USACO Section 3.3: Riding the Fences
典型的找欧拉路径的题.先贴下USACO上找欧拉路径的法子: Pick a starting node and recurse on that node. At each step: If the no ...
- USACO Section 3.3 Camlot(BFS)
BFS.先算出棋盘上每个点到各个点knight需要的步数:然后枚举所有点,其中再枚举king是自己到的还是knight带它去的(假如是knight带它的,枚举king周围的2格(网上都这么说,似乎是个 ...
- [IOI1996] USACO Section 5.3 Network of Schools(强连通分量)
nocow上的题解很好. http://www.nocow.cn/index.php/USACO/schlnet 如何求强连通分量呢?对于此题,可以直接先用floyd,然后再判断. --------- ...
- USACO Section 5.3 Big Barn(dp)
USACO前面好像有类似的题目..dp(i,j)=min(dp(i+1,j),dp(i+1,j+1),dp(i,j+1))+1 (坐标(i,j)处无tree;有tree自然dp(i,j)=0) .d ...
- USACO Section 1.3 Prime Cryptarithm 解题报告
题目 题目描述 牛式的定义,我们首先需要看下面这个算式结构: * * * x * * ------- * * * <-- partial product 1 * * * <-- parti ...
- USACO Section 1.1 Your Ride Is Here 解题报告
题目 问题描述 将字符串转变为数字,字母A对应的值为1,依次对应,字母Z对应的值为26.现在有一个字符串,将其中的每个字符转变为数字之后进行累乘,最终的结果对47求余数. 题目给你两个字符串,其中的字 ...
- USACO Section 1.1-1 Your Ride Is Here
USACO 1.1-1 Your Ride Is Here 你的飞碟在这儿 众所周知,在每一个彗星后都有一只UFO.这些UFO时常来收集地球上的忠诚支持者.不幸的是,他们的飞碟每次出行都只能带上一组支 ...
- USACO section 1.1 C++题解
USACO section1.1:DONE 2017.03.03 TEXT Submitting Solutions DONE 2017.03.04 PROB Your Ride Is Here [A ...
- USACO Section 1.1PROB Your Ride Is Here
题目传送门 不能提交哦 http://www.nocow.cn/index.php/Translate:USACO/ride /* ID: jusonal1 PROG: ride LANG: C+ ...
随机推荐
- MariaDB第三章(select)
基本查询 --查询基本使用(条件,排序,聚合函数,分组,分页) --创建学生表 create table students ( id int unsigned not null auto_increm ...
- margin不生效问题
问题机型 魅族M353 Android 5.0.1 问题描述 设置了margin-top: 15px; 但是在该机型上不生效 解决方案 使用padding 替代 margin
- 浏览器跨域请求之credentials
-时间起源- 前段时间,需要弄个简单的网站出来,访问远程的api服务. 我是这么做的.首先是在搭建一个nodejs服务来运行前端页面.在我请求登录的时候,能成功返回相应的成功信息.然后,当我再次请求读 ...
- linux-安装-源码安装
编译安装 tengine
- leetcode 730 Count Different Palindromic Subsequences
题目链接: https://leetcode.com/problems/count-different-palindromic-subsequences/description/ 730.Count ...
- 简话h5唤起本地app
在没接触这个功能之前,查询各种文档后也只是似懂非懂,做过之后,发现其实很简单,简言之就是通过一个iframe或者a标签来跳转app端提供的URL schema(至于这个URL schema的组成格式, ...
- python 中的集合set
python中,集合(set)是一个无序排列,可哈希, 支持集合关系测试,不支持索引和切片操作,没有特定语法格式, 只能通过工厂函数创建.集合里不会出现两个相同的元素, 所以集合常用来对字符串或元组或 ...
- eclipse jee使用
eclipse jee 安装 已经安装过elipse for Java,不知道会不会冲突? 查过,原来,你就算安装多个elipse for java都没事,更不用说jee.我选择的是eclipse-i ...
- PAT 1019 数字黑洞
https://pintia.cn/problem-sets/994805260223102976/problems/994805302786899968 给定任一个各位数字不完全相同的4位正整数,如 ...
- Java与JavaScript之间关于JSON的是非恩怨
http://blog.csdn.net/joyhen/article/details/43271569 js 单引号替换成双引号,双引号替换成单引号 操作 解决问题的场景: Java端生成了JSON ...