結果

問題 No.170 スワップ文字列(Easy)
ユーザー takatowintakatowin
提出日時 2017-01-17 00:37:10
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 611 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 25,212 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 16:36:39
合計ジャッジ時間 1,074 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 0 ms
4,376 KB
testcase_08 AC 0 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 0 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 0 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:24:3: warning: implicit declaration of function ‘gets’; did you mean ‘fgets’? [-Wimplicit-function-declaration]
   gets(s);
   ^~~~
   fgets
/tmp/ccUyd7BP.o: In function `main':
main.c:(.text.startup+0x13): warning: the `gets' function is dangerous and should not be used.

ソースコード

diff #

#include<stdio.h>
#include<string.h>
void sort(char *p){
  int i,j;
  char temp;
  for(i=strlen(p);i>0;i--){
    for(j=0;j<i-1;j++){
      if(p[j]>p[j+1]){
        temp=p[j];
        p[j]=p[j+1];
        p[j+1]=temp;
      }
    }
  }
}
int f(int a){
  if(a==1 || a==0)
    return 1;
  else return a*f(a-1);
}
int main(void){
  int i=0,j=0,k=1,t[9],temp=-1;
  char s[9];
  gets(s);
  sort(s);
  for(i=0;i<9;i++)
    t[i]=1;
  for(i=0;i<strlen(s)-1;i++){
    if(s[i]==s[i+1])
      t[j]++;
    else
      j++;
  }

  for(i=0;i<9;i++)
    k*=f(t[i]);
  temp+=f(strlen(s))/k;
  printf("%d\n",temp);
  return 0;
}

0