天天看点

9.25课件

http://ybt.ssoier.cn:8088/problem_show.php?pid=2004

#include <bits/stdc++.h>
using namespace std;

int main() {
	freopen("data.in", "r", stdin);
	freopen("1.out", "w", stdout);

	int n;
	cin >> n;
	
	if (n % 2 == 1) cout << -1 << endl;
	else {
		while (n) {
			int t = pow(2, (int)log2(n));
			cout << t << ' ';
			n -= t;		
		}
	}

	return 0;
}
           
#include <bits/stdc++.h>
using namespace std;

int main() {
	freopen("data.in", "r", stdin);
	freopen("2.out", "w", stdout);
	
	int n;
	cin >> n;
	
	if (n & 1 == 1) cout << -1 << endl;
	else {
		stack <int> s;
		while (n) {
			s.push(n & -n);
			n -= n & -n;
		}
		while (s.size()) {
			cout << s.top() << ' ';
			s.pop(); 
		}
	}

	return 0;
}
           
#include <bits/stdc++.h>
using namespace std;

int myrand() {
	return (rand()<<16) + (rand()<<1) + (rand()&1);
}

int main() {
	freopen("data.in", "w", stdout);
	
	srand(time(0));
	
	int n = myrand();	
	cout << n << endl;

	return 0;
}
           
@echo off

:loop

make_file
1
2

fc 1.out 2.out

if errorlevel  == 1 pause
goto loop
           
@echo off

:loop

echo ~~~~~~~~~~~~~~~~~~~
make_file
echo 输入 
type data.in

echo 输出: 
type 1.out
echo ~~~~~~~~~~~~~~~~~~~

pause

goto loop
           
#include <bits/stdc++.h>
using namespace std;

int myrand() {
	//三个部分都要加上括号,才能得到想要的随机数 
	return (rand()<<16) + (rand()<<1) + (rand()&1);
}

int main() {
	freopen("data.in", "w", stdout);

//	cout << time(0); 
	//如果不引人时间作为随机数种子,则每次得到的随机数序列都是一样的 
	srand(time(0));
	
//	int n = myrand();	
//	cout << n << endl;

	int minn = 1e9;
	int maxx = 0;
	for (int i = 1; i <= 1000000; i ++) {
		int t = rand();
		cout << t << endl;
		minn = min(minn, t);
		maxx = max(maxx, t);
	}
	
	//rand()函数返回值范围 [0~32767]
	cout << minn << endl;
	cout << maxx << endl;

	return 0;
}
           
9.25课件
9.25课件
9.25课件
9.25课件

继续阅读