zoukankan      html  css  js  c++  java
  • Codeforces Round #636 (Div. 3)题解

     

     白给题1

    #include <bits/stdc++.h>
    using namespace std;
    int main () {
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	int t;
    	cin >> t;
    	while(t--) {
    		int n;
    		cin >> n;
    		for(int k = 2;  (1 << k) - 1 <= n; ++k) {
    			if(n % ((1 << k) - 1) == 0) {
    				cout << n / ((1 << k) - 1) << endl;
    				break;
    			}
    		}
    	}
    }
    

     

     

     白给题2

    #include <bits/stdc++.h>
    using namespace std;
    int main () {
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	int t;
    	cin >> t;
    	while(t--) {
    		int n;
    		cin >> n;
    		if(n % 4 != 0) {
    			cout << "NO" << endl;
    			continue;
    		}
    		cout << "YES" << endl;
    		for(int i = 1; i <= n / 2; ++i) {
    			cout << 2 * i << " ";
    		}
    		for(int i = 1; i < n / 2; ++i) {
    			cout << 2 * i - 1 << " ";
    		}
    		cout << n + n / 2 - 1 << endl;
    	}
    }
    

     

     

     白给题3

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int main () {
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	int t;
    	cin >> t;
    	while(t--) {
    		int n;
    		cin >> n;
    		std::vector<ll> v;
    		for(int i = 0; i < n; ++i) {
    			ll temp;
    			cin >> temp;
    			v.push_back(temp);
    		}
    		int op = 0;
    		int top = 0;
    		op = v[0] > 0 ? 1 : -1;
    		ll maxx = v[0];
    		ll ans = 0;
    		for(int i = 1; i < n; ++i) {
    			top = v[i] > 0 ? 1 : -1;
    			if(top != op) {
    				ans += maxx;
    				op = top;
    				maxx = v[i];
    			}
    			else {
    				maxx = max(maxx, v[i]);
    			}
    		}
    		ans += maxx;
    		cout << ans << endl;
    	}
    }
    

     后面题待更新。。。

    作者:LightAc
    出处:https://www.cnblogs.com/lightac/
    联系:
    Email: dzz@stu.ouc.edu.cn
    QQ: 1171613053
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。
  • 相关阅读:
    DS博客作业03--树
    C博客作业05--指针
    C博客作业04--数组
    C博客作业03--函数
    C博客作业02--循环结构
    顺序分支结构
    我的第一篇博客
    第1次任务:购物车程序的面向对象设计
    5-互评-OO之接口-DAO模式代码阅读及应用
    第三周-面向对象基础与类的识别-自主学习任务
  • 原文地址:https://www.cnblogs.com/lightac/p/12750108.html
Copyright © 2011-2022 走看看