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+ ...
随机推荐
- Item 9: 比起typedef更偏爱别名声明(alias declaration)
本文翻译自modern effective C++,由于水平有限,故无法保证翻译完全正确,欢迎指出错误.谢谢! 博客已经迁移到这里啦 我确信我们都同意使用STL容器是一个好主意,并且我希望在Item ...
- 牛客多校第三场-A-PACM Team-多维背包的01变种
题目我就不贴了...说不定被查到要GG... 题意就是我们需要在P,A,C,M四个属性的限制下,找到符合条件的最优解... 这样我们就需要按照0/1背包的思路,建立一个五维度数组dp[i][j][k] ...
- zifutongji
第三次作业要求我们自己写程序,我算我们班写的比较晚的了,我听他们写的都是在文件中写一段代码,然后读出来.我们班大部分都是,所以,我就想可不可以跟他们不一样呢,写一个属于自己的思路. 所以我想到了数组. ...
- Individual Project-word frequency
预计时间: 项目要求理解:半小时 c#语言了解:6小时 构思程序框架:2小时 编写调试程序:4小时 项目实际完成时间: 项目要求理解:半小时 c#语言了解:6小时 构思程序框架:2小时 编写调试程序: ...
- 《Linux内核设计与分析》第十七章读书笔记
设备与模块 关于设备驱动和设备管理,四种内核成分. 设备类型:在所有Unix 系统中为了统一普通设备的操作所采用的分类. 模块: Linux 内核中用于按需加载和卸载目标码的机制. 内核对象:内核数据 ...
- <<梦断代码>>阅读笔记三
看完了这最后三分之一的<梦断代码>,意味着这本软件行业的著作已经被我粗略地过了一遍. 在这最后三分之一的内容中,我深入了解了在大型软件项目的运作过程中存在的困难和艰辛.一个大型软件项目的成 ...
- JAVA SOCKET编程单线程简单实例
服务端: package socketProgram; import java.io.BufferedReader;import java.io.IOException;import java.io. ...
- Fake NP CodeForces - 805A (思维)
Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following pro ...
- ThinkCMF项目部署出现无法加载数据库驱动解决方案
最近有个TP项目刚从从本地部署到阿里云服务器上,出现了无法加载数据库驱动的错误,提示 :( 无法加载数据库驱动: Think\Db\Driver 这里分享一下出现该错误的解决步骤: 首先记得项目部署到 ...
- #Leetcode# 977. Squares of a Sorted Array
https://leetcode.com/problems/squares-of-a-sorted-array/ Given an array of integers A sorted in non- ...