我是靠谱客的博主 彩色树叶,这篇文章主要介绍2017南宁区域赛 A.Abiyoyo B.The Chosen One,现在分享给大家,希望可以做个参考。

 A. Abiyoyo(水题)

   题意:

    输出k个Abiyoyo, Abiyoyo.,然后输出两个 Abiyoyo, yo yoyo yo yoyo.

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <bits/stdc++.h> using namespace std; int main(){ int t; cin >> t; while(t--){ int k; cin >> k; for(int i = 1; i <= k; i++){ cout << "Abiyoyo, Abiyoyo." << endl; } cout << "Abiyoyo, yo yoyo yo yoyo." << endl; cout << "Abiyoyo, yo yoyo yo yoyo." << endl; } return 0; }

 B.The Chosen One

题意:

  给个n,每次删去在奇数位上的数,求最后剩下的数是几

举例 n = 8;

1 , 2 , 3, 4, 5, 6, 7, 8

2, 4, 6, 8

4, 8

8

题解:

 (考虑的话,就是能够整除2 最多次数的数)

  先模拟打表,然后会发现答案就是离n最近的2的指数

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { BigInteger n; Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); while(t != 0) { n = scanner.nextBigInteger(); BigInteger ans = new BigInteger("2"); BigInteger k = new BigInteger("2"); while(ans.compareTo(n) == -1 || ans.compareTo(n) == 0) { ans = ans.multiply(k); } System.out.println(ans.divide(new BigInteger("2"))); t--; } scanner.close(); } }

 

最后

以上就是彩色树叶最近收集整理的关于2017南宁区域赛 A.Abiyoyo B.The Chosen One的全部内容,更多相关2017南宁区域赛内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(66)

评论列表共有 0 条评论

立即
投稿
返回
顶部