wojiaocbj

Untitled

May 3rd, 2022
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.11 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6. #include <time.h>
  7. #pragma warning(disable:4996)
  8. typedef long long LL;
  9. typedef unsigned long long ULL;
  10. char s1[114514] = { 0 }, s2[114514] = { 0 };
  11. int main(){
  12.     int m, n, i, j, flag1 = 0, flag2 = 0;
  13.     int count1[30] = { 0 }, count2[30] = { 0 };
  14.     scanf("%s%s", s1, s2);
  15.     m = strlen(s1);
  16.     n = strlen(s2);
  17.     if(m > n){
  18.         puts("Single Forever!");
  19.     }
  20.     else{//m<n
  21.         for(i = 0; i < m; i++){
  22.             count1[s1[i] - 'a'] += 1;
  23.             count2[s2[i] - 'a'] += 1;
  24.         }
  25.         flag1 = 1;
  26.         for(i = 0; i < 26; i++){
  27.             if(count1[i] != count2[i]){
  28.                 flag1 = 0;
  29.                 break;
  30.             }
  31.         }
  32.         if(flag1){
  33.             puts("65472");
  34.         }
  35.         else{
  36.             for(j = m; j < n; j++){
  37.                 count2[s2[j - m] - 'a'] -= 1;
  38.                 count2[s2[j] - 'a'] += 1;
  39.                 flag1 = 1;
  40.                 if(flag2){
  41.                     break;
  42.                 }
  43.                 for(i = 0; i < 26; i++){
  44.                     if(count1[i] != count2[i]){
  45.                         flag1 = 0;                 
  46.                         break;
  47.                     }
  48.                 }
  49.                 if(flag1){
  50.                     flag2 = 1;
  51.                 }
  52.             }
  53.             if(flag2){
  54.                 puts("65472");
  55.             }
  56.             else{
  57.                 puts("Single Forever!");
  58.             }
  59.         }
  60.     }
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment