結果
| 問題 | 
                            No.171 スワップ文字列(Med)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             akakimidori
                         | 
                    
| 提出日時 | 2018-04-18 20:19:33 | 
| 言語 | C90  (gcc 12.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 4 ms / 1,000 ms | 
| コード長 | 833 bytes | 
| コンパイル時間 | 192 ms | 
| コンパイル使用メモリ | 23,808 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-27 04:32:54 | 
| 合計ジャッジ時間 | 869 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 | 
コンパイルメッセージ
main.c: In function ‘run’:
main.c:16:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |   scanf("%s",s);
      |   ^~~~~~~~~~~~~
            
            ソースコード
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
typedef long long int int64;
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define POS(i,j) ((i)*(n+1)+(j))
void run(void){
  const int mod=573;
  char s[1001];
  scanf("%s",s);
  int n=0;
  while(s[n]!='\0') n++;
  int c[26];
  int i;
  for(i=0;i<26;i++) c[i]=0;
  for(i=0;i<n;i++) c[s[i]-'A']++;
  int *comb=(int *)calloc((n+1)*(n+1),sizeof(int));
  comb[POS(0,0)]=1;
  for(i=1;i<=n;i++){
    comb[POS(i,0)]=1;
    int j;
    for(j=1;j<=i;j++){
      comb[POS(i,j)]=(comb[POS(i-1,j-1)]+comb[POS(i-1,j)])%mod;
    }
  }
  int ans=1;
  int t=n;
  for(i=0;i<26-1;i++){
    ans=ans*comb[POS(t,c[i])]%mod;
    t-=c[i];
  }
  ans=(ans-1+mod)%mod;
  printf("%d\n",ans);
  return;
}
int main(void){
  run();
  return 0;
}
            
            
            
        
            
akakimidori