首页 > 其他分享 >How to ak 【LGR-145-Div.4】洛谷入门赛 #14?

How to ak 【LGR-145-Div.4】洛谷入门赛 #14?

时间:2023-07-15 09:13:23浏览次数:46  
标签:145 洛谷 48 int ak putchar include top define

A 数字判断

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define re register
#define lll __int128
#define gc getchar
#define pt putchar
#define int long long

using namespace std;
const int SIZE=1<<14;

inline int read(){
	re int x=0;re bool f=0;static char ch=gc();
	while(!(ch>=48&&ch<=57)&&ch!=EOF){if(ch=='-')f=1;ch=gc();}
	while(ch>=48&&ch<=57){x*=10;x+=(ch-48);ch=gc();}
	if(f)return -x;else return x;
}

void print(int x){
	char st[105];re int top=0;
	if(x==0)putchar('0');if(x<0)putchar('-');
	while(x){if(x>0)st[++top]=x%10+48;else st[++top]=-(x%10)+48;x/=10;}
	while(top)putchar(st[top--]);
}

void println(int x){
	print(x);putchar('\n');
}

void printsp(int x){
	print(x);putchar(' ');
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c<=100&&b%5==0&&c%7==0&&a-b>b-c)
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

B 团伙首领

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define re register
#define lll __int128
#define gc getchar
#define pt putchar
#define int long long

using namespace std;
const int SIZE=1<<14;

inline int read(){
	re int x=0;re bool f=0;static char ch=gc();
	while(!(ch>=48&&ch<=57)&&ch!=EOF){if(ch=='-')f=1;ch=gc();}
	while(ch>=48&&ch<=57){x*=10;x+=(ch-48);ch=gc();}
	if(f)return -x;else return x;
}

void print(int x){
	char st[105];re int top=0;
	if(x==0)putchar('0');if(x<0)putchar('-');
	while(x){if(x>0)st[++top]=x%10+48;else st[++top]=-(x%10)+48;x/=10;}
	while(top)putchar(st[top--]);
}

void println(int x){
	print(x);putchar('\n');
}

void printsp(int x){
	print(x);putchar(' ');
}

int a[1000006];
int f[1000006]; 
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int maxn=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		f[a[i]]++;
		maxn=max(maxn,a[i]);
	}
	int ans=0;
	for(int i=1;i<=maxn;i++)
		if(f[i])ans++;
	cout<<ans<<endl;
	return 0;
}

C 枚举结构

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define re register
#define lll __int128
#define gc getchar
#define pt putchar
#define int long long

using namespace std;
const int SIZE=1<<14;

inline int read(){
	re int x=0;re bool f=0;static char ch=gc();
	while(!(ch>=48&&ch<=57)&&ch!=EOF){if(ch=='-')f=1;ch=gc();}
	while(ch>=48&&ch<=57){x*=10;x+=(ch-48);ch=gc();}
	if(f)return -x;else return x;
}

void print(int x){
	char st[105];re int top=0;
	if(x==0)putchar('0');if(x<0)putchar('-');
	while(x){if(x>0)st[++top]=x%10+48;else st[++top]=-(x%10)+48;x/=10;}
	while(top)putchar(st[top--]);
}

void println(int x){
	print(x);putchar('\n');
}

void printsp(int x){
	print(x);putchar(' ');
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	char x,z;
	int y,w;
	cin>>x;
	cin>>y;
	cin>>z;
	cin>>w;
	if('a'<=x&&x<='z'&&'a'<=z&&z<='z'&&x==z){
		cout<<"valid"<<endl;
		if(y<=w){
			cout<<w-y+1<<endl;
		}
		else cout<<y-w+1<<endl;
	}
		
	else {
		cout<<"Invalid"<<endl;
		cout<<-1<<endl;
	}
	
	return 0;
}

D 塔台超频

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define re register
#define lll __int128
#define gc getchar
#define pt putchar
#define int long long

using namespace std;
const int SIZE=1<<14;

inline int read(){
	re int x=0;re bool f=0;static char ch=gc();
	while(!(ch>=48&&ch<=57)&&ch!=EOF){if(ch=='-')f=1;ch=gc();}
	while(ch>=48&&ch<=57){x*=10;x+=(ch-48);ch=gc();}
	if(f)return -x;else return x;
}

void print(int x){
	char st[105];re int top=0;
	if(x==0)putchar('0');if(x<0)putchar('-');
	while(x){if(x>0)st[++top]=x%10+48;else st[++top]=-(x%10)+48;x/=10;}
	while(top)putchar(st[top--]);
}

void println(int x){
	print(x);putchar('\n');
}

void printsp(int x){
	print(x);putchar(' ');
}

int a[500005],b[500005];
int n,maxn;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i]>>b[i];
	for(int i=2;i<=n;i++){
		int x=a[i]-a[i-1];
		if(x<=b[i-1])continue;
		else maxn=max(maxn,x-b[i-1]);
	}
	cout<<maxn<<endl;
	return 0;
}

E 署前街少年

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define re register
#define lll __int128
#define gc getchar
#define pt putchar
#define int long long

using namespace std;
const int SIZE=1<<14;

inline int read(){
	re int x=0;re bool f=0;static char ch=gc();
	while(!(ch>=48&&ch<=57)&&ch!=EOF){if(ch=='-')f=1;ch=gc();}
	while(ch>=48&&ch<=57){x*=10;x+=(ch-48);ch=gc();}
	if(f)return -x;else return x;
}

void print(int x){
	char st[105];re int top=0;
	if(x==0)putchar('0');if(x<0)putchar('-');
	while(x){if(x>0)st[++top]=x%10+48;else st[++top]=-(x%10)+48;x/=10;}
	while(top)putchar(st[top--]);
}

void println(int x){
	print(x);putchar('\n');
}

void printsp(int x){
	print(x);putchar(' ');
}

int a[5000006];
int f[5000006];
int p[5000006];
int ph[50000006];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=2*n;i++)
		cin>>a[i];
	for(int i=1;i<=2*n;i++){
		if(i%2==0)f[i]=0;
		else f[i]=1;
	}
	
	for(int i=1;i<=2*n;i++){
		p[i]=i%k;
	}
		
	for(int i=1;i<=2*n;i++){
		ph[p[i]]+=a[i];
	}
	
	for(int i=1;i<=2*n;i++)
		if(i%2==1)a[i]=ph[p[i]]%i;
	
	for(int i=1;i<=2*n;i++)
		cout<<a[i]<<' ';
	return 0;
}

F 扶苏和串

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define re register
#define lll __int128
#define gc getchar
#define pt putchar
#define int long long

using namespace std;
const int SIZE=1<<14;

inline int read(){
	re int x=0;re bool f=0;static char ch=gc();
	while(!(ch>=48&&ch<=57)&&ch!=EOF){if(ch=='-')f=1;ch=gc();}
	while(ch>=48&&ch<=57){x*=10;x+=(ch-48);ch=gc();}
	if(f)return -x;else return x;
}

void print(int x){
	char st[105];re int top=0;
	if(x==0)putchar('0');if(x<0)putchar('-');
	while(x){if(x>0)st[++top]=x%10+48;else st[++top]=-(x%10)+48;x/=10;}
	while(top)putchar(st[top--]);
}

void println(int x){
	print(x);putchar('\n');
}

void printsp(int x){
	print(x);putchar(' ');
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s,now,ans;
	cin>>s;
	ans=s;
	int len=s.length();
	for(int i=0;i<len;i++) 
		for(int j=i;j<len;j++){
			now=s;
			for(int k=0;k<=(j-i)/2;k++)
				swap(now[i+k],now[j-k]);
			if(now<ans)
			ans=now;
		}
		
	cout<<ans<<endl;
	return 0;
}

G Three-View Projection

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define re register
#define lll __int128
#define gc getchar
#define pt putchar
#define int long long

using namespace std;
const int SIZE=1<<14;

inline int read(){
	re int x=0;re bool f=0;static char ch=gc();
	while(!(ch>=48&&ch<=57)&&ch!=EOF){if(ch=='-')f=1;ch=gc();}
	while(ch>=48&&ch<=57){x*=10;x+=(ch-48);ch=gc();}
	if(f)return -x;else return x;
}

void print(int x){
	char st[105];re int top=0;
	if(x==0)putchar('0');if(x<0)putchar('-');
	while(x){if(x>0)st[++top]=x%10+48;else st[++top]=-(x%10)+48;x/=10;}
	while(top)putchar(st[top--]);
}

void println(int x){
	print(x);putchar('\n');
}

void printsp(int x){
	print(x);putchar(' ');
}

int a[1005][1005];
int zheng[1005];
int zuo[1005];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	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(a[i][j]==1){
				zheng[i]=1;
				zuo[j]=1;
			}
		}
		
	for(int i=1;i<=n;i++)
		cout<<zheng[i]<<' ';
	cout<<endl;
	for(int i=m;i>=1;i--)
		cout<<zuo[i]<<' ';
	
	cout<<endl;
			
	for(int i=m;i>=1;i--){
		for(int j=1;j<=n;j++)
			cout<<a[j][i]<<' ';
		cout<<endl;
	}

	return 0;
}

H 魔法少女扶苏

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define re register
#define lll __int128
#define gc getchar
#define pt putchar
#define int long long

using namespace std;
const int SIZE=1<<14;

inline int read(){
	re int x=0;re bool f=0;static char ch=gc();
	while(!(ch>=48&&ch<=57)&&ch!=EOF){if(ch=='-')f=1;ch=gc();}
	while(ch>=48&&ch<=57){x*=10;x+=(ch-48);ch=gc();}
	if(f)return -x;else return x;
}

void print(int x){
	char st[105];re int top=0;
	if(x==0)putchar('0');if(x<0)putchar('-');
	while(x){if(x>0)st[++top]=x%10+48;else st[++top]=-(x%10)+48;x/=10;}
	while(top)putchar(st[top--]);
}

void println(int x){
	print(x);putchar('\n');
}

void printsp(int x){
	print(x);putchar(' ');
}

int a[1005][1005];
	int n,m,k;

bool get_ans(int num){
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			int sum=0;
			for(int x=1;x<=n;x++)
				sum+=a[x][j]-num;
			for(int y=1;y<=m;y++)
				sum+=a[i][y]-num;
			sum+=num;
			if(a[i][j]>=sum)ans++;
		}
	if(ans>=k)return true;
	else return false;
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	
	int l=0;
	int r=1919810;	
	while(l+1!=r){
		int mid=(l+r)/2;
		if(get_ans(mid)){
			r=mid;
		}
		else l=mid;
	}
	cout<<r<<endl;
	return 0;
}

I std::string

#include <iostream>

using namespace std;

int main() {
  int taskId;
  cin >> taskId;
  if (taskId == 1) {
    cout << "100000" <<endl;
  } else if (taskId == 2) {
    cout << "3 0 1 0" << endl;
  } else { // 这个 else 不会被执行
    cout << "Stupid Fusu!" << endl;
  }
}

标签:145,洛谷,48,int,ak,putchar,include,top,define
From: https://www.cnblogs.com/CheZiHe929/p/17555526.html

相关文章

  • 145.观察者模式和发布订阅模式有什么不同
    145.观察者模式和发布订阅模式有什么不同?发布订阅模式其实属于广义上的观察者模式在观察者模式中,观察者需要直接订阅目标事件。在目标发出内容改变的事件后,直接接收事件并作出响应。而在发布订阅模式中,发布者和订阅者之间多了一个调度中心。调度中心一方面从发布者接收事件,......
  • 131.Set和WeakSet结构
    131.Set和WeakSet结构?1.ES6提供了新的数据结构Set。它类似于数组,但是成员的值都是唯一的,没有重复的值。2.WeakSet结构与Set类似,也是不重复的值的集合。但是WeakSet的成员只能是对象,而不能是其他类型的值。WeakSet中的对象都是弱引用,即垃圾回收机制不考虑WeakSet......
  • 洛谷 P6667 [清华集训2016] 如何优雅地求和
    洛谷传送门点值不好搞。考虑把它搞成系数一类的东西。由二项式反演,\(f(x)=\sum\limits_{i=0}^x\binom{x}{i}b_i\Leftrightarrowb_i=\sum\limits_{j=0}^i\binom{i}{j}(-1)^{i-j}f(j)\)。然后我们要求:\[\sum\limits_{k=0}^n\sum\limits_{i=0}^ms_i\bino......
  • 洛谷 P3372 【模板】线段树 1
    题目传送门题目描述如题,已知一个数列,你需要进行下面两种操作:1.将某一个数加上x2.求出某区间每一个数的和输入格式第一行包含两个整数N、M,分别表示该数列数字的个数和操作的总个数。第二行包含N个用空格分隔的整数,其中第i个数字表示数列第i项的初始值。接下来M行每行包含3......
  • Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass
    pom文件中JDK是1.8项目的jdk17只需要统一一下jdk即可......
  • 使用HttpUtil时报javax.net.ssl.SSLHandshakeException: No appropriate protocol异常
    在使用HttpUtil类时,针对某一个接口报错出现异常HttpGetInforesult=HttpUtil.getInfo(token,Url);但是这个getInfoUrl在postman上调用是成功的后来查找后发现问题是:在Java8及高版本以上的版本在调用ssl时会出现javax.net.ssl.SSLHandshakeException:Noappropriateprotoc......
  • 工程开发 | CMake工程目录结构和多线程
    CMake工程目录结构lib:生成的库文件src:源文件(.cpp.cc)include:头文件(.h.hpp)build:一般在这个文件夹下执行cmake..(..之前有一个空格,表示你要使用的CMakeLists.txt文件在当前的上层路径),生成的Makefile文件也在这个路径下。bin:一般放生成的可执行文件CMakeLists.t......
  • Delta Lake_ High-Performance ACID Table Storage over Cloud Object Stores
    论文发表于2020年,研究数据湖产品的很好的学习资料.概要开篇很明确的表明了为什么要做Deltalake这样一个产品.Databricks尝试将数据仓库直接架在云上对象存储之上,这种尝试的过程中遇到了对象存储的一些问题,为了解决这些问题,提出了Deltalake这套技术方案.对象存储的......
  • __attribute__((weak))
    参见:https://blog.csdn.net/q2519008/article/details/827747741.场景A,B两个模块,A模块调用了不确定B模块是否提供了函数,但是又不得不调用,这个时候在A模块中再申明一个弱符号函数,即用weak,如果外部提供了调用外部的,如果没提供调用申明的。2.弱符号若两个或两个以上全局符号(函......
  • CMake使用
    makefile依赖于不同编译平台,CMake可以跨平台。通过编写CMakeLists.txt文件,执行cmake命令,就可以自动生成对应平台的makefile文件,再执行命令make就能进行编译语法变量使用${}取值,if语句中直接使用变量名指令格式为:指令(参数1参数2),指令大小写无关,参数和变量大小写相关基本指令......