HDU 3788 ZOJ问题
生活随笔
收集整理的這篇文章主要介紹了
HDU 3788 ZOJ问题
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
http://acm.hdu.edu.cn/showproblem.php?pid=3788
上HDU看到滾動(dòng)條‘浙大研究生復(fù)試上機(jī)考試’最近熱議的話題是考研的分?jǐn)?shù)下來了。想直接找工作的我,也在猶豫的邊緣,挑了了道題做了一下。
代碼寫的挫死了..o(╯□╰)o
1. zoj ac
2.xxxzojxxx zoj左右兩邊的o的數(shù)量一樣多
3.azbojac 其中它是由xxzojxx一次遞歸而來的.假設(shè)為ozojo(a=1, b=1, c=1)遞歸而來的,那么一次是ozojo -->ozoojoo --> ozooojooo
可以發(fā)現(xiàn)numa是不變的。numb每次+1,那么變換次數(shù)為numb-1。因此要滿足2.條可以推出,numc-(numb-1)*numa==numa --> numc==numa*numb;
代碼如下:
#include<stdio.h> #include<string.h> int main() {char ch[1005];int i, len, numa, numb, numc, plaz, plaj;while(gets(ch)){int flag=1;len=strlen(ch);plaz=-1, plaj=-1;for(i=0; i<len; i++)if(ch[i]=='z'){ plaz=i;break;}for(i=0; i<len; i++)if(ch[i]=='j'){plaj=i;break;}if(plaz==-1||plaj==-1)flag=0;if(flag==0){printf("Wrong Answer\n");continue;}numa=0, numb=0, numc=0;for(i=0; i<plaz; i++){if(ch[i]!='o'){flag=0;break;}numa++;}for(i=plaz+1; i<plaj; i++){if(ch[i]!='o'){flag=0;break;}numb++;}for(i=plaj+1; i<len; i++){if(ch[i]!='o'){flag=0;break;}numc++;}if(flag==0){printf("Wrong Answer\n");continue;}if(plaj-plaz>1){if(numc==numa*numb) printf("Accepted\n");elseprintf("Wrong Answer\n");}elseprintf("Wrong Answer\n");}return 0; }
轉(zhuǎn)載于:https://www.cnblogs.com/Hilda/archive/2013/02/23/2923469.html
總結(jié)
以上是生活随笔為你收集整理的HDU 3788 ZOJ问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android从零开始(七)
- 下一篇: redhat 5.6下网卡冗余实验