1 条题解
-
0
C++ :
#include<iostream> using namespace std; int main() { char x; int k=0,t,n,ans=1,i; cin>>n; while(1) {cin>>x; if(x=='Q')break; cin>>t; k++; n-=t; } ans=1; for(i=-1;i<k-1;i++) ans*=(n-i); cout<<ans; }
Python :
# coding=utf-8 def main(): N = int(input()) C = [] while True: temp = input() if temp == 'Q': break else: C.append(int(temp.split()[1])) N_color = len(C) N_space = N - sum(C) cnt_color = 1 for i in range(1, N_color+1): cnt_color *= i cnt_space = 1 nn = N_space - N_color + 1 for i in range(nn): cnt_space *= N_space + 1 - i for i in range(1, nn + 1): cnt_space /= i print(int(cnt_color*cnt_space)) if __name__ == '__main__': main()
- 1
信息
- ID
- 169
- 时间
- 1000ms
- 内存
- 125MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者