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+ ...
随机推荐
- Asp.net MVC 中Ajax的使用
Asp.net MVC 抛弃了Asp.net WebForm那种高度封装的控件,让我们跟底层的HTML有了更多的亲近.可以更自由.更灵活的去控制HTML的结构.样式和行为.而这点对于Ajax 的应有来 ...
- Netdata---Linux系统性能实时监控平台部署记录
通常来说,作为一个Linux的SA,很有必要掌握一个专门的系统监控工具,以便能随时了解系统资源的占用情况.下面就介绍下一款Linux性能实时监测工具-Netdata,它是Linux系统实时性能监测工具 ...
- shell脚本之特殊符号总结性梳理
# 井号 (comments) 这几乎是个满场都有的符号#!/bin/bash 井号也常出现在一行的开头,或者位于完整指令之后,这类情况表示符号后面的是注解文字,不会被执行. # This line ...
- og标签对SEO的作用及用法
meta property=og标签对SEO的作用及用法,如果你仔细观察会发现本站点<head>代码中有一段:"property="og:image"这段代码 ...
- Why yarn
http://www.cnblogs.com/LeftNotEasy/archive/2012/02/18/why-yarn.html https://www.ibm.com/developerwor ...
- Spring及Spring Boot 国内快速开发框架
http://www.javacoder.top/home.jsp# http://springboot.fun/ 一个常用的支付子项目 https://gitee.com/52itstyle/spr ...
- dip vs di vs ioc
https://stackoverflow.com/questions/6766056/dip-vs-di-vs-ioc https://docs.microsoft.com/en-us/aspnet ...
- HTML使用button的一个小坑
https://www.w3schools.com/TAGs/att_button_type.asp Definition and Usage The type attribute specifies ...
- Java的JDK下Hashtable与HashMap的区别
时间角度: Hashtable * @since JDK1.0 ; HashMap* @since 1.2 基类与接口角度: public class Hashtable<K,V> e ...
- [转帖]数据中心网络里的Underlay和Overlay
数据中心网络里的Underlay和Overlay https://blog.csdn.net/zjc801blog/article/details/54289683 2017年01月09日 15:47 ...