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+ ...
随机推荐
- [UWP 自定义控件]了解模板化控件(7):支持Command
以我的经验来说,要让TemplatedControl支持Command的需求不会很多,大部分情况用附加属性解决这个需求会更便利些,譬如UWPCommunityToolkit的HyperlinkExte ...
- checkpoint-BLCR部署和测试(源码)
1. 概述2. 部署过程2.1 源码下载2.2 解压安装2.3 添加库环境2.4 插入内核模块3. 测试3.1 创建测试程序3.2 功能测试4. 参考博客 1. 概述 checkpoint 2. 部署 ...
- Redis常用操作-------Set(集合)
1.SADD key member [member ...] 将一个或多个 member 元素加入到集合 key 当中,已经存在于集合的 member 元素将被忽略. 假如 key 不存在,则创建一个 ...
- Popush End
coconut: (咳咳)作为一名后台开发者,我觉得自己在这次作业完成中最大的收获就是跟node.js的异步模型打交道.首先我得出了一个这样的结论:异步模型能够提高服务器的高性能并发请求,但是却加大了 ...
- SCRUM 12.23
距离第二轮迭结束只有几天了. 我们全体组员现在的工作方向都在应用测试上. 明天的任务分配如下 成员 已完成任务 新任务 彭林江 落实API 自动爬虫测试 王卓 提升爬虫程序性能 正确性测试 郝倩 提升 ...
- rabbitMq与spring boot搭配实现监听
在我前面有一篇博客说到了rabbitMq实现与zk类似的watch功能,但是那一篇博客没有代码实例,后面自己补了一个demo,便于理解.demo中主要利用spring boot的配置方式, 一.消费者 ...
- 2-Twenty Fifth Scrum Meeting-20151231
前言 因为服务器关闭,我们的开发项目也遭遇停滞一个星期.与网站开发负责人员协商之后,29号开放服务器.我们的项目也能够继续下去.比规定的开发时间(截止为2015/12/29)推迟. 事项安排 1.开发 ...
- [Beta阶段]展示博客
一.团队成员简介与个人博客地址 团队博客地址:http://www.cnblogs.com/wowotoubuaa/ 江昊,项目经理http://www.cnblogs.com/haoj/ 王开,后端 ...
- [北航矩阵理论A]课程笔记
[北航矩阵理论A]课程笔记 一.特征值 特征根相关: 设任一方阵 \(A = (a_{ij})_{n\times n} \in C^{n\times n}\) 特征多项式 \(T(\lambda)=| ...
- mysql执行 sql文件遇到USING BTREE ) ENGINE=MyISAM DEFAULT CHARSET=utf8错误
使用navcat在导入别人发的mysql数据的时候,报了下面这个错误: [Err] 1064 - You have an error in your SQL syntax; check the man ...