/*
ID:bbezxcy1
PROG: milk2
LANG: C++
*/
#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
bool vis[1200000];
int main()
{
freopen("milk2.in","r",stdin );
freopen("milk2.out","w",stdout );
int n,i,j,a,b,c,d,ans1,ans2;
while(scanf("%d",&n)!=EOF)
{
c=1200000,d=0;
memset(vis,0,sizeof(vis));
for(i=0;i<n;i++)
{
scanf("%d%d",&a,&b);
b--;
for(j=a;j<=b;j++)
{
vis[j]=1;
}
c=min(a,c);
d=max(b,d);
}
a=0,b=0;
ans1=ans2=0;
for(i=c;i<=d;i++)
{
if(vis[i]==1)
{
a=0;
b++;
ans1=max(b,ans1);
}
else
{
b=0;
a++;
ans2=max(a,ans2);
}
}
printf("%d %d\n",ans1,ans2);
}
return 0;
}
/*
ID:bbezxcy1
PROG: transform
LANG: C++
*/
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char str[20][20],cha1[20][20],cha2[20][20],cha[20][20],dir[20][20];
bool check(int n){
int i,j,a,b,c;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(dir[i][j]!=cha[i][j]){
return 0;
}
}
}
return 1;
}
void change1(int n){
int i,j,k,a,b,c;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
cha[i][j]=str[n-j-1][i];
}
}
}
void change2(int n){
int i,j,a,b,c;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
cha[i][j]=str[n-j-1][i];
}
}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
cha1[i][j]=cha[n-j-1][i];
}
}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
cha[i][j]=cha1[i][j];
}
}
}
void change3(int n){
int i,j,a,b,c;
change2(n);
for(i=0;i<n;i++){
for(j=0;j<n;j++){
cha[i][j]=cha1[n-j-1][i];
}
}
}
void change4(int n){
int i,j,k,a,b,c;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
cha[i][j]=str[i][n-j-1];
}
}
}
char cpy[20][20];
bool change5(int n){
int i,j;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
cpy[i][j]=str[i][j];
}
}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
str[i][j]=cpy[i][n-j-1];
}
}
change1(n);
if(check(n))return 1;
change2(n);
if(check(n))return 1;
change3(n);
if(check(n))return 1;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
str[i][j]=cpy[i][j];
}
}
return 0;
}
bool change6(int n){
int i,j,k,a,b,c;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(str[i][j]!=dir[i][j]){
return 0;
}
}
}
return 1;
}
int main(){
int n,i,j,k,l;
freopen("transform.in","r",stdin );
freopen("transform.out","w",stdout );
while(scanf("%d",&n)!=EOF){
for(i=0;i<n;i++){
scanf("%s",str[i]);
}
for(i=0;i<n;i++){
scanf("%s",dir[i]);
}
change1(n);
if(check(n)){
printf("1\n");
continue;
}
change2(n);
if(check(n)){
printf("2\n");
continue;
}
change3(n);
if(check(n)){
printf("3\n");
continue;
}
change4(n);
if(check(n)){
printf("4\n");
continue;
}
if(change5(n)){
printf("5\n");
continue;
}
if(change6(n)){
printf("6\n");
}
else{
printf("7\n");
}
}
return 0;
}
/*
ID:bbezxcy1
PROG: namenum
LANG: C++
*/
#include<iostream>
#include<cstring>
#include<fstream>
#include<cstdio>
#include<map>
using namespace std;
ifstream tin("dict.txt");
class nodea{
public:
int id;
nodea *p[30];
nodea(){
int i;
id=-1;
for(i=0;i<30;i++)p[i]=NULL;
}
};
nodea *root;
int cnt;
bool flag;
int getnum(char *s){
int i;
nodea *r=root;
int l=strlen(s);
for(i=0;i<l;i++){
if(r->p[s[i]-'A']==NULL){
r->p[s[i]-'A']=new nodea();
}
r=r->p[s[i]-'A'];
}
if(r->id==-1){
r->id=cnt;
cnt++;
}
return r->id;
}
const char key[20][3] = {
{ 0, 0, 0 }, { 0, 0, 0 },
{ 'A', 'B', 'C' }, { 'D', 'E', 'F' }, { 'G', 'H', 'I' }, { 'J', 'K', 'L' },
{ 'M', 'N', 'O' }, { 'P', 'R', 'S' }, { 'T', 'U', 'V' }, { 'W', 'X', 'Y' }
};
char str[20],cha[20];
int tot,len;
void dfs(int dep){
if(dep==len){
cha[dep]='\0';
if(getnum(cha)<tot){
printf("%s\n",cha);
flag=1;
}
return;
}
for(int i=0;i<3;i++){
cha[dep]=key[str[dep]-'0'][i];
dfs(dep+1);
}
}
int main(){
cnt=1;
root=new nodea();
while(tin>>str){
if(str[0]=='0')break;
getnum(str);
}
freopen("namenum.in","r",stdin );
freopen("namenum.out","w",stdout );
tot=cnt;
flag=0;
scanf("%s",str);
len=strlen(str);
dfs(0);
if(!flag)printf("NONE\n");
return 0;
}
/*
ID:bbezxcy1
PROG: palsquare
LANG: C++
*/
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int num[1000];
bool ispar(int a,int n){
int b=a;
int c=0;
while(b){
num[c++]=b%n;
b/=n;
}
for(int i=0;i<c;i++){
if(num[i]!=num[c-i-1]){
return 0;
}
}
return 1;
}
void print(int a,int n){
int b=a;
int c=0;
while(b){
num[c++]=b%n;
b/=n;
}
for(int i=c-1;i>=0;i--){
if(num[i]<10){
printf("%d",num[i]);
}
else{
printf("%c",num[i]-10+'A');
}
}
}
int main(){
int n;
freopen("palsquare.in","r",stdin );
freopen("palsquare.out","w",stdout );
while(scanf("%d",&n)!=EOF){
for(int i=1;i<=300;i++){
if(ispar(i*i,n)){
print(i,n);
printf(" ");
print(i*i,n);
printf("\n");
}
}
}
return 0;
}
/*
ID:bbezxcy1
PROG: dualpal
LANG: C++
*/
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int num[1000000];
bool ispar(int a,int n){
int b=a;
int c=0;
while(b){
num[c++]=b%n;
b/=n;
}
for(int i=0;i<c;i++){
if(num[i]!=num[c-i-1]){
return 0;
}
}
return 1;
}
int main(){
int n,s,i,j,a,b,c;
freopen("dualpal.in","r",stdin );
freopen("dualpal.out","w",stdout );
while(scanf("%d%d",&n,&s)!=EOF){
a=s;
for(i=n;i>0;){
a++;
b=0;
for(j=2;j<=10;j++){
if(ispar(a,j)){
b++;
}
}
if(b>=2){
i--;
printf("%d\n",a);
}
}
}
return 0;
}
分享到:
相关推荐
usaco 3到6章讲解
usaco section2.3--section5.5源程序。。。。。。。。。。。。。。。。
usaco测试数据+标程 usaco的section1到section5的所有测试数据 以及标准程序
USACO1-5单元AC的代码~ 1 Chapter1 1.1 Section 1.1 1.2 Section 1.2 1.3 Section 1.3 1.4 Section 1.4 1.5 Section 1.5 2 Chapter2 2.1 Section 2.1 2.2 Section 2.2 2.3 Section 2.3 2.4 Section 2.4 3 Chapter3 ...
pku acm上的一系列usaco题目都可以在这里找到测试数据以及源代码,不过题目的名字和pku上有得有点出入,需要自己去比较一下,2002年
pku acm上的一系列usaco题目都可以在这里找到测试数据以及源代码,不过题目的名字和pku上有得有点出入,需要自己去比较一下,2001年
USACO题目,Greedy Gift Givers
此c++代码实现了USACO上Bessie Come Home的问题,并运用了弗洛伊德算法
此C++程序是实现了USACO网站上的Magic Squares的问题。
资源包包括USACO 2001-2007年月赛的测试数据;usaco月赛十年题典(2000-2009),usaco月赛2002-2008题解。单独下载需资源分30分以上。为了方便编程爱好者,我这边统一下载打包。欢迎下载。
这是USACO2001-2007月赛全集。 usaco是美国中学生的官方竞赛网站。是美国著名在线题库,专门为信息学竞赛选手准备。推荐直接阅读英语原文,既准确可靠又可提高英语水平。做题方式模拟正式比赛,采用标准测评机、文件...
Notes-USACO-2021-弹簧
USACO chapter one.May hope it useful to someone
usaco 2010-2011 nov news,喜欢usaco的朋友可以看看
USACO chapter two.Useful for beginners.
我的USACO题解和程序
USACO培训网站 我为章节解决方案。 每个文件的多行USACO标识信息注释 第1章全部的解决方案 第2章全部的解决方案
Java中的USACO金问题 YYMM 姓名 文件夹 笔记 代码 1812 美食 1812 牛适应性 1812 团队合作
USACO培训页面美国计算机奥林匹克训练页2015年6月17日开始
丰富的USACO1.1--2.3.4的所有题解