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+ ...
随机推荐
- WEB 小案例 -- 网上书城(四)
针对于这个小案例我们今天讲解结账操作,也是有关这个案例的最后一次博文,说实话这个案例的博文写的很糟糕,不知道该如何去表述自己的思路,所以内容有点水,其实说到底还是功力不够. 处理思路 点击结账,发送结 ...
- ansible一键部署k8s单机环境
一.虚拟机准备 干净的Centsot7.4.4G内存.2个CPU 最小化安装,最好带虚拟化 二.执行初始化脚本 注意:脚本中配置静态网卡根据实际网卡名称配置,我用的是ens33 可以用 sed -i ...
- 基于SimpleChain Beta的跨链交互与持续稳态思考
1. 区块链扩展性迷局 比特币作为第一个区块链应用与运行到目前为止最被信任的公链,其扩展性问题却持续被作为焦点贯穿着整个链的发展周期.事实上,在2009年1月4日比特币出现的那一天到2010年10月1 ...
- HTML5-indexedDB使用常见错误总结
indexedDB使用过程中常常会出现以下错误: Failed to execute ‘createObjectStore’ on ‘IDBDatabase’: The database is not ...
- react/React Native 在 import 导入时,有的带花括号{},有的不带原理解析
在使用import引用模块时,如何正确使用{} 例如:有两个文件,home.js.user.js 一:不使用{}: 当需要在home.js中引入user.js的时候 //home.js 文件中impo ...
- Linux内核第二节
作者:武西垚 深入理解函数调用堆栈 堆栈是C语言程序运行时必须的一个记录调用路径和参数的空间 堆栈的作用 函数调用框架 传递参数 保存返回地址 提供局部变量空间 堆栈相关的寄存器 esp,堆栈指针,指 ...
- SQL大杂烩
DML 语句(数据操作语言)Insert.Update. Delete.Merge DDL 语句(数据定义语言)Create.Alter. Drop.Truncate DCL 语句(数据控制语言)Gr ...
- PHP开发:Eclipse版环境配置
软件: 1.eclipse php版本下载地址:http://www.eclipse.org/downloads/packages/eclipse-php-developers/heliosr 2.A ...
- Practice3 阅读《构建之法》1-5章
第一章:概论 本章主要是讲了软件工程的基本概念,软件工程的最终目标是创造“足够好”的软件. 提出问题:什么是BUG?(出自1.2.5节) 答:就我个人而言,在许多游戏中也有许多的BUG,BUG这一词在 ...
- PAT 1066 图像过滤
https://pintia.cn/problem-sets/994805260223102976/problems/994805266514558976 图像过滤是把图像中不重要的像素都染成背景色, ...