日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

2019江西省赛F - String

發(fā)布時(shí)間:2023/12/8 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 2019江西省赛F - String 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Avin has a string. He would like to uniform-randomly select four characters (selecting the same character is allowed) from it. You are asked to calculate the probability of the four characters being ”avin” in order.

Input

The first line contains n (1 ≤ n ≤ 100), the length of the string. The second line contains the string. To simplify the problem, the characters of the string are from ’a’, ’v’, ’i’, ’n’.

Output

Print the reduced fraction (the greatest common divisor of the numerator and denominator is 1), representing the probability. If the answer is 0, you should output “0/1”.

Sample Input

4
avin
4
aaaa

Sample Output

1/256
0/1

這道題真的超簡(jiǎn)單,結(jié)果在定義的時(shí)候著急了,馬虎了,找了好久的錯(cuò)誤才找到。

#include"stdio.h" #include"math.h" int gcd(int o,int p) {return p==0?o:gcd(p,o%p);} int main() {int n;char a[150];int x;while(~scanf("%d",&n)){int sum=1;int sum1=0;int sum2=0;int sum3=0;int sum4=0;scanf("%s",a);for(int i=0;i<n;i++){if(a[i]=='a'){sum1++;}if(a[i]=='v'){sum2++;}if(a[i]=='i'){sum3++;}if(a[i]=='n'){sum4++;}}for(int i=0;i<4;i++){sum=sum*n;}x=sum1*sum2*sum3*sum4;if(x!=0){if(gcd!=0){printf("%d/%d\n",x/gcd(x,sum),sum/gcd(x,sum));}else{printf("%d/%d\n",x,sum);}}else{printf("0/1\n");}}return 0; }

總結(jié)

以上是生活随笔為你收集整理的2019江西省赛F - String的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。