Algorithm training of Quantum team (20190908)

Algorithm training of Quantum team (20190908)
A - An easy problem
In this problem you need to make a multiply table of N * N ,just like the sample out. The element in the i th row and j th column should be the product(乘積) of i and j.
Input
The first line of input is an integer C which indicate the number of test cases.

Then C test cases follow.Each test case contains an integer N (1<=N<=9) in a line which mentioned above.
Output
For each test case, print out the multiply table.
Sample Input
2
1
4
Sample Output
1
1 2 3 4
2 4 6 8
3 6 9 12
4 8 12 16
Hint
There is no blank space at the end of each line.

#include<stdio.h>
int main() {
	int i,j,c,n;
	scanf("%d",&c);
	while(c--) {
		scanf("%d",&n);
		if(n==1) printf("1\n");
		else {
			for(i=1; i<=n; i++) {
				for(j=1; j<=n; j++) {
					if(j==1) printf("%d",i*j);
					else  printf(" %d",i*j);
				}
				printf("\n");
			}
		}
	}
	return 0;
}
/*
2
1
4
*/

B - 三足鼎立
MCA山中人才輩出,洞悉外界戰火紛紛,山中各路豪傑決定出山拯救百姓於水火,曾以題數掃全場的威士忌,曾經高數九十九的天外來客,曾以一劍鑄十年的亦紛菲,歃血爲盟,盤踞全國各個要塞(簡稱全國賽)遇敵殺敵,遇佛殺佛,終於擊退遼軍,暫時平定外患,三人位置也處於穩態。

可惜遼誓不甘心,遼國徵南大將軍<耶律javac++>欲找出三人所在逐個擊破,現在他發現威士忌的位置s,天外來客的位置u,不過很難探查到亦紛菲v所在何處,只能知道三人滿足關係:

arctan(1/s) = arctan(1/u)+arctan(1/v)

注: (其中0 <= x <= 1)
定義 f(s, u, v) = vu-su-s*v 的值 爲<三足鼎立>

<耶律javac++>想計算<三足鼎立>的值
Input
首先輸入一個t,表示有t組數據,跟着t行:
輸入s, u (s <= 12^3, u <= 2^20 且 s, u, v > 0)
且s,u,v均爲實數
Output
輸出 vu-su-s*v 的值,爲了簡單起見,如果是小數,直接取整

比如:答案是1.7 則輸出 1

Sample Input
1
1 2
Sample Output
1

#include"bits/stdc++.h"
using namespace std;
int main() {
	int t;
	cin>>t;
	while(t--) {
		double a,b;
		cin>>a>>b;
		cout<<"1"<<endl;
	}
	return 0;
}
/*
1
1 2
*/
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章