【队伍训练2】 AtCoder Beginner Contest 165

2020-09-11 15:13:24 浏览数 (1)

A 水题:

代码语言:javascript复制
#include<bits/stdc  .h>

using namespace std;

int main(){
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    for(int i=1;;i  ){
    	if(i*k > b) {
    		cout<<"NG"<<endl;
    		break;
		}
		if(i*k>=a && i*k<=b){
			cout<<"OK"<<endl;
			break;
		}
	}
	return 0;
} 

B 水题:但是会卡精度!!!

代码语言:javascript复制
#include<bits/stdc  .h>

using namespace std;

typedef unsigned long long ull;

int main(){
    ull x;
    cin>>x;
    ull sum = 100;
    ull tot = 0;
    while(sum<x){
    	ull res = sum /100;
    	//cout<<res<<"0---";
    	sum  = res;
    	tot  ;
	}
	cout<<tot;
	return 0;
} 

C dfs

代码语言:javascript复制
#include<bits/stdc  .h>
using namespace std;
typedef long long ll;

const int inf = 0x3f3f3f3f;

struct node{
	int a,b,c,d;
}t[60]; 

int n,m,q,ans,s[20];

void dfs(int nw,int st){
	if(nw > n){
		int res = 0;
		for(int i = 1;i <= q;  i){
			if(s[t[i].b] - s[t[i].a] == t[i].c)
				res  = t[i].d;
		}
		ans = max(ans,res);
		return ;
	}
	for(int i = st;i <= m;  i){
		s[nw] = i;
		dfs(nw 1,i);
	}
	return ;
}
int main(){
	cin >> n >> m >> q;
	for(int i = 1;i <= q;i  ){
		scanf("%d %d %d %d",&t[i].a,&t[i].b,&t[i].c,&t[i].d);
	}
	ans = -inf;
	
	dfs(1,1);
	
	cout<<ans<<endl;
    return 0;
}

D 数学思维题

代码语言:javascript复制
#include<bits/stdc  .h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;



int main(){
	ll a,b,n;
	cin>>a>>b>>n;
	ll flag=-inf;

	if(n < b){
		cout<<(a*n)/b<<endl;
		return 0;
	} 
	else{
		flag = max(a*(b-1)/b,flag);
		flag = max(flag,(a*n)/b-a*(n/b));
	}
	cout<<flag<<endl;
	return 0;
}

0 人点赞