結果
| 問題 |
No.170 スワップ文字列(Easy)
|
| コンテスト | |
| ユーザー |
takatowin
|
| 提出日時 | 2017-01-17 00:37:10 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 611 bytes |
| コンパイル時間 | 183 ms |
| コンパイル使用メモリ | 22,016 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 00:45:53 |
| 合計ジャッジ時間 | 894 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:24:3: warning: implicit declaration of function ‘gets’; did you mean ‘fgets’? [-Wimplicit-function-declaration]
24 | gets(s);
| ^~~~
| fgets
/usr/bin/ld: /tmp/cc5avxDv.o: in function `main':
main.c:(.text.startup+0x2d): 警告: the `gets' function is dangerous and should not be used.
ソースコード
#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;
}
takatowin