签到题
AC代码
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<cmath>
#include<sstream>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<list>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define PII pair<int,int>
#define inf 0x3f3f3f3f
#define endl "\n"
typedef long long ll;
using namespace std;
const double pi = acos(-1.0);
int t,n,m,k;
string s;
void solve()
{
cin >> t;
while(t--){
cin >> s;
for(int i = 0 ; i < s.size() ; i++){
if(s[i] >= 'a' && s[i] <= 'z') s[i] -= 32;
}
if(s == "YES") cout << "yes" << endl;
else cout << "no" << endl;
}
}
int main() {
IOS;
solve();
return 0;
}
签到二
AC代码
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<cmath>
#include<sstream>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<list>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define PII pair<int,int>
#define inf 0x3f3f3f3f
#define endl "\n"
typedef long long ll;
using namespace std;
const double pi = acos(-1.0);
int t,n,m,k;
string s;
void solve()
{
cin >> t;
while(t--){
cin >> n >> s;
map <char,int> mp;
for(int i = 0 ; i < s.size() ; i++) mp[s[i]]++;
int ans = 0;
for(auto it : mp){
ans += it.second + 1;
}
cout << ans << endl;
}
}
int main() {
IOS;
solve();
return 0;
}
签到三:
AC代码
#include <bits/stdc++.h>
using namespace std;
void solve()
{
int n;
cin >> n;
int a[n];
for(int i = 0; i < n; i++)
{
cin >> a[i];
}
for(int i = 0; i < n; i++)
{
int b;
cin >> b;
if(b == 0)
{
continue;
}
string now;
cin >> now;
for(int j = 0; j < b; j++)
{
if(now[j] == 'U'){a[i]--;}
else if(now[j] == 'D'){a[i]++;}
if(a[i] < 0){a[i]+=10;}
if(a[i] > 9){a[i]-=10;}
}
}
for(int i = 0; i < n; i++)
{
cout << a[i] << " ";
}
cout << endl;
}
int main(){
int t;
cin>> t;
while(t--)
{
solve();
}
return 0;
}
签到四:
思路:用map提前存好字符串,然后暴力截取字符串,看map中是否存在即可
AC代码
#include <bits/stdc++.h>
using namespace std;
const int MAX = 200007;
const int MOD = 1000000007;
void solve() {
int n;
cin >> n;
string s[n];
map<string, bool> mp;
for (int i = 0; i < n; i++) {
cin >> s[i];
mp[s[i]] = true;
}
for (int i = 0; i < n; i++) {
bool ok = false;
for (int j = 1; j < s[i].length(); j++) {
string pref = s[i].substr(0, j), suff = s[i].substr(j, s[i].length() - j);
if (mp[pref] && mp[suff]) {ok = true;}
}
cout << ok;
}
cout << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tt; cin >> tt; for (int i = 1; i <= tt; i++) {solve();}
// solve();
}
找规律题 :
举例 : n = 4, n = 5
然后发现规律后递推即可
#include<bits/stdc++.h>
using namespace std;
const int N=105;
string s[N];
int main(){
int t;cin>>t;
while(t--){
int n,ans=0;cin>>n;
for(int i=0;i<n;i++)cin>>s[i];
for(int i=0;i<n;i++)
for(int j=0;j<n;j++){
int t=s[i][j]-'0'+s[j][n-i-1]-'0'+s[n-i-1][n-j-1]-'0'+s[n-j-1][i]-'0';
if(t==1||t==3)ans++;
if(t==2)ans+=2;
}
cout<<ans/4<<endl;
}
return 0;
}
F. Yet Another Problem About Pairs Satisfying an Inequality
思路: 把题目要求式子分解: ai < i , i < aj, aj < j;
第一个和第三个式子可以看成一个,所以满足ai < i 的情况后,只需要看有多少组i < aj
AC代码
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<cmath>
#include<sstream>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<list>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define PII pair<int,int>
#define inf 0x3f3f3f3f
#define endl "\n"
typedef long long ll;
using namespace std;
const double pi = acos(-1.0);
int t,n,m,k;
string s;
void solve()
{
cin >> t;
while(t--){
cin >> n;
int a[n + 1];
vector <int> b;
for(int i = 1 ; i <= n ;i++){
cin >> a[i];
if(a[i] < i) b.push_back(i);
}
ll ans = 0;
for(int i = 1 ; i < b.size() ; i++){
int pos = lower_bound(b.begin(),b.end(),a[b[i]]) - b.begin();
ans += pos;
}
cout << ans << endl;
}
}
int main() {
IOS;
solve();
return 0;
}
本弱弱不会,下次一定