BestCoder Round #36(Strange Class-類比),

來源:互聯網
上載者:User

BestCoder Round #36(Strange Class-類比),

Strange ClassAccepts: 519Submissions: 1749Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)問題描述
在Vivid的學校裡,有一個奇怪的班級(SC).在SC裡,這些學生的名字非常奇怪。他們的名字形式是這樣的a n b n c n  (a,b,c兩兩不相同。).例如,叫”abc”,”ddppqq”的學生是在SC裡的,然而叫”aaa”,”ab”,”ddppqqq”的同學並不是在SC裡的。Vivid交了許多的朋友,他想知道他們之中哪些人是在SC裡的。
輸入描述
多組測試資料(大概10 組),每一個資料在一行中給出一個字串S,代表Vivid一個朋友的名字。請處理到檔案末尾。[參數約定]1≤|S|≤10. |S| 是指S的長度.S 只包含小寫字母.
輸出描述
對於每一個資料,如果Vivid的朋友是SC裡的,那麼輸出YES,否則輸出NO。
輸入範例
abcbc
輸出範例
YESNO
Statistic |Submit | Clarifications | Back

類比


#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>#include<functional>#include<iostream>#include<cmath>#include<cctype>#include<ctime>using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++)#define Rep(i,n) for(int i=0;i<n;i++)#define ForD(i,n) for(int i=n;i;i--)#define RepD(i,n) for(int i=n;i>=0;i--)#define Forp(x) for(int p=pre[x];p;p=next[p])#define Forpiter(x) for(int &p=iter[x];p;p=next[p])  #define Lson (x<<1)#define Rson ((x<<1)+1)#define MEM(a) memset(a,0,sizeof(a));#define MEMI(a) memset(a,127,sizeof(a));#define MEMi(a) memset(a,128,sizeof(a));#define INF (2139062143)#define F (100000007)#define MAXN (1000000)typedef long long ll;ll mul(ll a,ll b){return (a*b)%F;}ll add(ll a,ll b){return (a+b)%F;}ll sub(ll a,ll b){return (a-b+(a-b)/F*F+F)%F;}void upd(ll &a,ll b){a=(a%F+b%F)%F;}int n;char s[MAXN];int main(){//freopen("a.in","r",stdin);//freopen(".out","w",stdout);while(scanf("%s",s)==1){n=strlen(s);if (n%3!=0||n<3) cout<<"NO"<<endl;else{int t=n/3;if (s[0]==s[t]||s[t]==s[2*t]||s[0]==s[2*t]) cout<<"NO"<<endl;else{bool flag=0;For(i,n-1)if ((s[i]!=s[i-1]&&i%t!=0)) {flag=1;break;}if (flag) cout<<"NO"<<endl;else cout<<"YES"<<endl;}}}return 0;}



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.