假期欢乐赛 参考程序

参考程序
A

# include <iostream>
using namespace std;
int main(){
	int ji, tu, tou, jiao;
	cin>> tou>> jiao;
	ji = (4 * tou - jiao) / 2;
	tu = tou - ji;
	if(jiao % 2 == 1 || jiao < tou * 2 || jiao > tou * 4)
		cout<< "No answer"<< endl;
	else
		cout<< ji<< " "<< tu<< endl;
	return 0;
 } 

B

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>

using namespace std ;

long long a11 , a12 , a21 , a22 , b1 , b2 ;
long long opp = 1 ;
bool firstx = 1 , scay ;
char x , y ;
double ansx , ansy ;

int main(){
	//freopen("test09.in","r",stdin);
	//freopen("test09.out","w",stdout) ;
	char c = getchar() ;
	long long now = 0 , zf = 1 ;
	bool sca = false ;
	while(true){
		if(c <= 'z' && c >= 'a'){
			if(firstx){
				x = c , firstx = false ;
				if(now == 0 && !sca)	a11 += opp * zf , sca = false ;
				else	a11 += opp * now * zf , sca = false , now = 0 , zf = 1 ;
			}
			else if (c == x){
				if(now == 0 && !sca)	a11 += opp * zf , sca = false ;
				else	a11 += opp * now * zf , sca = false , now = 0 , zf = 1 ;
			}
			else{
				y = c , scay = 1 ;
				if(now == 0 && !sca)	a12 += opp * zf , sca = false ;
				else	a12 += opp * now * zf , sca = false , now = 0 , zf = 1 ;
			}
		}
		else if(c == '-'){
			b1 += -opp * now * zf , sca = false , now = 0 , zf = -1 ;
		}
		else if(c == '+'){
			b1 += -opp * now * zf , sca = false , now = 0 , zf = 1 ;
		}
		else if(c == '='){
			b1 += -opp * now * zf , sca = false , now = 0 , zf = 1 , opp = -opp ;
		}
		else if(c >= '0' && c <= '9'){
			now = now * 10 + c - '0' , sca = true ;
		}
		else {
			b1 += -opp * now * zf ;
			break ;
		}
		c = getchar() ;
	}
	opp = 1 , zf = 1 , now = 0 , sca = false ;
	while (c < '0' || c > '9'){
		c = getchar() ;
		if(c == '-'||(c <= 'z'&&c >= 'a'))	break ;
	}
	while(true){
		if(c <= 'z' && c >= 'a'){
			if (c == x){
				if(now == 0 && !sca)	a21 += opp * zf , sca = false ;
				else	a21 += opp * now * zf , sca = false , now = 0 , zf = 1 ;
			}
			else{
				y = c , scay = 1 ;
				if(now == 0 && !sca)	a22 += opp * zf , sca = false ;
				else	a22 += opp * now * zf , sca = false , now = 0 , zf = 1 ;
			}
		}
		else if(c == '-'){
			b2 += -opp * now * zf , sca = false , now = 0 , zf = -1 ;
		}
		else if(c == '+'){
			b2 += -opp * now * zf , sca = false , now = 0 , zf = 1 ;
		}
		else if(c == '='){
			b2 += -opp * now * zf , sca = false , now = 0 , zf = 1 , opp = -opp ;
		}
		else if(c >= '0' && c <= '9')
			now = now * 10 + c - '0' , sca = true ;
		else {
			b2 += -opp * now * zf ;
			break ;
		}
		c = getchar() ;
	}
	double m = (double)a21 / a11 , aa22 = (double)a22 - m * a12 , bb2 = (double)b2 - m * b1 ;
	ansy = (bb2 == 0 ? 0 : bb2 / aa22) ;
	double con = double(a12 )* ansy , cons = b1 - con ;
	//printf("%lf %lf\n" , con , cons) ;
	ansx = cons / a11 ;
	printf("%c=%lf\n", x , (ansx == 0 ? 0 : ansx)) ;
	if(scay)	printf("%c=%lf\n" , y , (ansy == 0 ? 0 : ansy)) ;
	//printf("%lld %lld %lld\n%lld %lld %lld\n",a11,a12,b1,a21,a22,b2) ;
	return 0 ;
} 

C

#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
const int N = 2e5+7,INF = 0x3f3f3f3f;
int q[N],s[N];
int main()
{
    int n,m;scanf("%d%d",&n,&m);
    for(int i = 1;i <= n;++i)
        scanf("%d",&s[i]),s[i] += s[i - 1];
    int l = 1,r = 1,res = -INF;
    for(int i = 1;i <= n;++i)
    {
        while(l <= r && q[l] < i - m)   ++l;
        res = max(res,s[i] - s[q[l]]);
        while(l <= r && s[q[r]] >= s[i])    --r;
        q[++r] = i;
    }
    cout << res;
    return 0;
}

D

#include<iostream>  
#include<cstring>  
#include<cmath>  
#include<cstdio>  
#include<algorithm>  
using namespace std;  
typedef long long ll;  
const int N=2000005;
ll sum[N];
int p[N],d[N],que[N],ok[N];
int n;
inline int getint()
{
	char c;
	while ((c = getchar()) < '0' || c > '9');
	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}
void DP1()
{
	int q1=1,q2=0;
	for (int i=1; i<=n; ++i){
		while (q1<=q2 && sum[que[q2]]>=sum[i]) --q2;
		que[++q2]=i;
	}
	for (int i=n+1; i<=n*2; ++i){
		while (q1<=q2 && sum[que[q2]]>=sum[i]) --q2;
		que[++q2]=i;
		while (q1<=q2 && que[q1]<=i-n) ++q1;
		if (sum[que[q1]]>=sum[i-n]) ok[i-n]=1;	
	}
}
void DP2()
{
	int q1=1,q2=0;
	for (int i=n*2; i>n; --i){
		while (q1<=q2 && sum[que[q2]]>=sum[i]) --q2;
		que[++q2]=i;
	}
	for (int i=n; i; --i){
		while (q1<=q2 && sum[que[q2]]>=sum[i]) --q2;
		que[++q2]=i;
		while (q1<=q2 && que[q1]>=i+n) ++q1;
		if (sum[que[q1]]>=sum[i+n]) ok[i]=1;		
	}
}
int main()  
{  
 	n=getint();
 	for (int i=1; i<=n; ++i){
		p[i+n]=p[i]=getint(), d[i+n]=d[i]=getint();
		sum[i]=sum[i-1]+p[i-1]-d[i-1];
 	}
 	for (int i=n+1; i<=n*2; ++i)sum[i]=sum[i-1]+p[i-1]-d[i-1];
 //	for (int i=1; i<=n*2; ++i) printf("%lld ",sum[i]);
 //	printf("\n");
 	DP1();
 	for (int i=n*2; i; --i) sum[i]=sum[i+1]+p[i+1]-d[i];
 //	for (int i=1; i<=n*2; ++i) printf("%lld ",sum[i]);
 	DP2();
 	for (int i=1; i<=n; ++i) printf("%s\n",ok[i]?"TAK":"NIE");
}  

E

# include <iostream>
using namespace std;

int main () {
    ios::sync_with_stdio (false);
    cout<< "Hello World!"<< endl;
    return 0;
}

F

# include <iostream>
# include <cstdio>
# include <cmath>
# include <algorithm>
using namespace std;

int a, b;
int main () {
	cin>> a>> b;
	if (a == b) {
		cout<< "maoge233"<< endl;
	}
	else {
		cout<< "maoge"<<endl;
	}
	return 0;
}

G

# include <iostream>
# include <cstdio>
# include <cstring>
# include <cmath>
# include <algorithm>
using namespace std;

int n, k;
char ch[20][20][20], a[20][20], c[20][20], chn[20], an;

bool bfline (int h) {
	for (int i = 1; i <= n; i++) {
		if (c[h][i] == '#') {
			return 0;
		}
	}
	return 1;
}
bool bfl (int h) {
	for (int i = 1; i <= n; i++) {
		if (c[i][h] == '#') {
			return 0;
		}
	}
	return 1;
}
void gaoa () {
	int sjline = 0, sjl = 0;
	for (; bfline (++sjline); );
	for (; bfl (++sjl); );
	int sline = sjline, sl = sjl - 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			a[i][j] = '.';
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (sl < n) {
				a[i][j] = c[sline][++ sl];
			}
			else if (sl > n) {
				break;
			}
		}
		if (sline < n) {
			sline++;
			sl = sjl - 1;
		}
		else {
			break;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (a[i][j] == '#') {
				an++;
			}
		}
	}
}
void gaoch (int h) {
	int sjline = 0, sjl = 0;
	for (; bfline (++sjline); );
	for (; bfl (++sjl); );
	int sline = sjline, sl = sjl - 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			ch[h][i][j] = '.';
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (sl < n) {
				ch[h][i][j] = c[sline][++sl];
			}
			else if (sl > n) {
				break;
			}
		}
		if (sline < n) {
			sline++;
			sl = sjl - 1;
		}
		else {
			break;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (ch[h][i][j] == '#') {
				chn[h] ++;
			}
		}
	}
}
bool gao (int h) {
	if (chn[h] > an)
		return 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			c[i][j] = a[i][j];
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (a[i][j] != ch[h][i][j] && ch[h][i][j] == '#')
				return 0;
			else if (a[i][j] == ch[h][i][j]) {
				c[i][j] = '.';
			}
		}
	}
	gaoch (15);
	return 1;
}
bool xd (int h) {
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (ch[h][i][j] != ch[15][i][j])
				return 0;
		}
	}
	return 1;
}

int main () {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> c[i][j];
		}
	}
	gaoa ();
	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= n; j++) {
			for (int h = 1; h <= n; h++) {
				cin >> c[j][h];
			}
		}
		gaoch (i);
	}
	for (int i = 1; i <= k; i++) {
		if (gao (i)) {
			for (int j = 1; j <= k; j++) {
				if (xd (j)) {
					if (i < j) {
						cout << i << " " << j << endl;
						return 0;
					}
					else {
						cout << j << " " << i << endl;
						return 0;
					}
					
				}
			}
		}
	}
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值