D题想复杂了,花了好多时间,感觉也没时间看F了,就来写个题解蹭蹭访问量把^_^
传送门:1335 A. Candies and Two Sisters
题意:你要把n个糖果分给两个人,两个人的糖果数不能相等,问你有几种分法。
题解:就是(n-1)/2
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<bits/stdc++.h> 2 #define ll long long 3 using namespace std; 4 5 int main() 6 { 7 ios::sync_with_stdio(false); 8 cin.tie(0); 9 cout.tie(0); 10 ll n; 11 ll t; 12 cin>>t; 13 while(t--){ 14 cin>>n; 15 cout<<(n-1)/2<<endl; 16 } 17 return 0; 18 }
传送门:1335 B. Construct the String
题意:给你三个数 n, a , b , 构造一个长度为n的字符串,每个长度为a的子串必须有b个不同的字母。
题解:前b个字符从 'a' 到 'a' + b - 1,然后从第b+1个开始,每个字符和第 i - b 个相等。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<bits/stdc++.h> 2 #define ll long long 3 using namespace std; 4 5 char s[100100]; 6 7 int main() 8 { 9 ios::sync_with_stdio(false); 10 cin.tie(0); 11 cout.tie(0); 12 int t; 13 cin>>t; 14 while(t--){ 15 int n,a,b; 16 cin>>n>>a>>b; 17 for(int i=0;i<b;i++) 18 s[i]='a'+i; 19 for(int i=b;i<n;i++){ 20 s[i]=s[i-b]; 21 } 22 s[n]='