河南萌新联赛2024第(二)场:南阳理工学院_ACM/NOI/CSP/CCPC/ICPC算法编程高难度练习赛_牛客竞赛OJ
重生之zbk要拿回属于他的一切
简单的,无所谓的判断一下下。
that's all。thank you。
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define inf 0x3f3f3f3f
#define pii pair<int,int>
const int N=100005;
const int mod=1e9+7;
//chuan
void solve() {
int n;
cin>>n;
string s;
cin>>s;
int sum=0;
for(int i=0;i<=n-5;i++){
if(s[i]=='c' and s[i+1]=='h' and s[i+2]=='u' and s[i+3]=='a' and s[i+4]=='n'){
sum++;
}
}
cout<<sum<<endl;
}
signed main() {
ios::sync_with_stdio ( false );cin.tie ( nullptr );cout.tie ( nullptr );
int oyyo = 1;
//cin >> oyyo;
while ( oyyo-- ) {
solve();
}
return 0;
}
这是签到
我爱线代,我爱线代,我爱线代。没有人比我更热爱线代。
No body know XianDai better than me!
保持线代的优雅。我们建立一个函数来计算3阶行列式。传入特定的三个列。这样就好了。我们不必看着很麻烦的i和j来烦恼了。
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define inf 0x3f3f3f3f
#define pii pair<int,int>
const int N=15;
const int mod=1e9+7;
int a[N][N];
int suan(int i,int j,int z){
int x=a[1][i]*a[2][j]*a[3][z]+a[1][j]*a[2][z]*a[3][i]+a[1][z]*a[2][i]*a[3][j]
-a[1][z]*a[2][j]*a[3][i]-a[1][j]*a[2][i]*a[3][z]-a[1][i]*a[3][j]*a[2][z];
return x;
}
void solve() {
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}
if(n<m){
for(int i=n+1;i<=m;i++){
for(int j=0;j<=m;j++){
a[i][j]=0;
}
}
}
if(n>m){
for(int i=1;i<=n;i++){
for(int j=m+1;j<=n;j++){
a[i][j]=0;
}
}
}
int n1=max(n,m);
int min1=inf;
for(int i=1;i<=n1;i++){
if(i==1){
min1=min(min1,a[i][i]);
}if(i==2){
int x=a[1][1]*a[2][2]-a[1][2]*a[2][1];
min1=min(min1,x);
}if(i==3){
int x=a[1][1]*a[2][2]*a[3][3]+a[1][2]*a[2][3]*a[3][1]+a[1][3]*a[2][1]*a[3][2]
-a[1][3]*a[2][2]*a[3][1]-a[1][2]*a[2][1]*a[3][3]-a[1][1]*a[3][2]*a[2][3];
min1=min(min1,x);
}
if(i==4){
int x1=a[4][1]*suan(2,3,4);
int x2=a[4][2]*suan(1,3,4);
int x3=a[4][3]*suan(1,2,4);
int x4=a[4][4]*suan(1,2,3);
int x=x1+x2+x3+x4;
min1=min(min1,x);
}
if(i==5){
int x5=a[5][5]*(a[4][1]*suan(2,3,4)+a[4][2]*suan(1,3,4)+a[4][3]*suan(1,2,4)+a[4][4]*suan(1,2,3));
int x1=a[5][1]*(a[4][2]*suan(3,4,5)+a[4][3]*suan(2,4,5)+a[4][4]*suan(2,3,5)+a[4][5]*suan(2,3,4));
int x2=a[5][2]*(a[4][1]*suan(3,4,5)+a[4][3]*suan(1,4,5)+a[4][4]*suan(1,3,5)+a[4][5]*suan(1,3,4));
int x3=a[5][3]*(a[4][1]*suan(2,4,5)+a[4][2]*suan(1,4,5)+a[4][4]*suan(1,2,5)+a[4][5]*suan(1,2,4));
int x4=a[5][4]*(a[4][1]*suan(2,3,5)+a[4][2]*suan(1,3,5)+a[4][3]*suan(1,2,5)+a[4][5]*suan(1,2,3));
int x=x1+x2+x3+x4+x5;
min1=min(min1,x);
}
}
cout<<min1<<endl;
}
signed main() {
ios::sync_with_stdio ( false );cin.tie ( nullptr );cout.tie ( nullptr );
int oyyo = 1;
//cin >> oyyo;
while ( oyyo-- ) {
solve();
}
return 0;
}
水灵灵的小学弟
open your eyes!;
国际旅行Ⅰ
根据题意可以得知国与国之间互相联通所以从任意一个国家出发都可以到其他所有国家,故按照权值排序后输出就可以了.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define inf 0x3f3f3f3f
#define pii pair<int,int>
const int N=100005;
const int mod=1e9+7;
void solve() {
int n,m,q;
cin>>n>>m>>q;
vector<int>a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
vector<int>u(m),v(m);
for(int i=0;i<m;i++){
cin>>u[i]>>v[i];
}
sort(a.begin(),a.end());
for(int i=0;i<q;i++){
int x;
cin>>x;
cout<<a[x-1]<<endl;
}
}
signed main() {
ios::sync_with_stdio ( false );cin.tie ( nullptr );cout.tie ( nullptr );
int oyyo = 1;
//cin >> oyyo;
while ( oyyo-- ) {
solve();
}
return 0;
}
狼狼的备忘录
代码就像山一样。
因为数据范围很小,所以我很随意的就去循环进行判断,用map来判断重复情况。用for循环来判断后缀与否。然后我为了记录尽可能多的数据用了很大的很杂的数据结构
最后用排序来做最后的调整。
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define inf 0x3f3f3f3f
#define pii pair<int,int>
const int N=15;
const int mod=1e9+7;
struct ren{
map<string,int>u;
vector<string>xing;
};
bool cmp(string a,string b){
return a.size()>b.size();
}
bool cmp1(string a,string b){
return a<b;
}
void solve() {
int n;
cin>>n;
map<string,ren>a;
map<string,int>b;
for(int i=0;i<n;i++){
string ss;
cin>>ss;
int x;
cin>>x;
for(int j=0;j<x;j++){
string s;
cin>>s;
if(a[ss].u[s]==0){
a[ss].xing.push_back(s);
a[ss].u[s]++;
}
}
}
for(auto&c:a){
sort(c.second.xing.begin(),c.second.xing.end(),cmp);
int n1=c.second.xing.size();
for(int i=0;i<n1;i++){
for(int j=i+1;j<n1 ;j++){
int k1=1;
int k2=0;
if(c.second.xing[i].size()>=c.second.xing[j].size()){
k2=1;
for(int z=0;z<c.second.xing[j].size();z++){
if(c.second.xing[i][c.second.xing[i].size()-1-z]!=c.second.xing[j][c.second.xing[j].size()-1-z]){
k1=0;
break;
}
}
}
if(k1==1 and k2==1){
for(int z=j+1;z<n1;z++){
c.second.xing[z-1]=c.second.xing[z];
}
c.second.xing.pop_back();
n1--;
j--;
}
}
}
b[c.first]=n1;
}
cout<<a.size()<<endl;
for(auto &c:a){
sort(c.second.xing.begin(),c.second.xing.end(),cmp1);
cout<<c.first<<" ";
cout<<b[c.first]<<" ";
for(auto& b:c.second.xing){
cout<<b<<" ";
}
cout<<endl;
}
}
signed main() {
ios::sync_with_stdio ( false );cin.tie ( nullptr );cout.tie ( nullptr );
int oyyo = 1;
//cin >> oyyo;
while ( oyyo-- ) {
solve();
}
return 0;
}
A*BBBB
#include <iostream>
#include <cstring>
#include<algorithm>
using namespace std;
void solve()
{
string a, b;
string ans;
cin >> a >> b;
reverse(begin(a), end(a));
int cur = 0, temp = 0;
for (int i = 0; i < a.size() + b.size(); i++)
{
//cur对应推导过程中的ans[i]
//temp 用来解决进位问题
if (i < a.size()) cur += a[i] - '0';
if (i >= b.size()) cur -= a[i - b.size()] - '0';
temp += cur * (b[0] - '0');
ans.push_back(temp % 10 + '0');
temp /= 10;
}
while (ans.size() > 1 && ans.back() == '0')
ans.pop_back();
reverse(begin(ans), end(ans));
cout << ans << "\n";
}
int main()
{
int t;
cin >> t;
while (t--)
solve();
return 0;
}