題目一
“ 改革春風(fēng)吹滿地,
不會(huì)AC沒(méi)關(guān)系;
實(shí)在不行回老家,
還有一畝三分地。
謝謝!(樂(lè)隊(duì)奏樂(lè))”
話說(shuō)部分學(xué)生心態(tài)極好,每天就知道游戲,這次考試如此簡(jiǎn)單的題目,也是云里霧里,而且,還竟然來(lái)這么幾句打油詩(shī)。
好呀,老師的責(zé)任就是幫你解決問(wèn)題,既然想種田,那就分你一塊。
這塊田位于浙江省溫州市蒼南縣靈溪鎮(zhèn)林家鋪?zhàn)哟澹噙呅涡螤畹囊粔K地,原本是linle 的,現(xiàn)在就準(zhǔn)備送給你了。不過(guò),任何事情都沒(méi)有那么簡(jiǎn)單,你必須首先告訴我這塊地到底有多少面積,如果回答正確才能真正得到這塊地。
發(fā)愁了吧?就是要讓你知道,種地也是需要AC知識(shí)的!以后還是好好練吧...
Input
輸入數(shù)據(jù)包含多個(gè)測(cè)試實(shí)例,每個(gè)測(cè)試實(shí)例占一行,每行的開始是一個(gè)整數(shù)n(3<=n<=100),它表示多邊形的邊數(shù)(當(dāng)然也是頂點(diǎn)數(shù)),然后是按照逆時(shí)針順序給出的n個(gè)頂點(diǎn)的坐標(biāo)(x1, y1, x2, y2... xn, yn),為了簡(jiǎn)化問(wèn)題,這里的所有坐標(biāo)都用整數(shù)表示。
輸入數(shù)據(jù)中所有的整數(shù)都在32位整數(shù)范圍內(nèi),n=0表示數(shù)據(jù)的結(jié)束,不做處理。
Output
對(duì)于每個(gè)測(cè)試實(shí)例,請(qǐng)輸出對(duì)應(yīng)的多邊形面積,結(jié)果精確到小數(shù)點(diǎn)后一位小數(shù)。
每個(gè)實(shí)例的輸出占一行。
Sample Input
3 0 0 1 0 0 1
4 1 0 0 1 -1 0 0 -1
0
Sample Output
0.5
2.0
代碼:package acm題目;
import java.util.Scanner;
public class acm3036 {
static int szx(int x1,int y1,int x2,int y2) {
return x1*y2-x2*y1;
}
public static void main(String[] args) {
? ? Scanner sc=new Scanner(System.in);
? ? int x[]=new int[100];
? ? int y[]=new int[100];
? ? while(sc.hasNext()) {
? ? int i;
? ? int n=sc.nextInt();
? ? if(n==0) return;
? ? double sum=0.0;
? ? for(i=0;i<n;i++) {
? ? x[i]=sc.nextInt();
? ? y[i]=sc.nextInt();
? ? }
? ? for(i=0;i<n-1;i++) {
? ? sum+=szx(x[i],y[i],x[i+1],y[i+1]);
? ? }
? ? sum+=x[i]*y[0]-x[0]*y[i];
? ? System.out.println(sum/2);
? ? }
}
}
題目二
Problem Description
“今年暑假不AC?”
“是的?!?/p>
“那你干什么呢?”
“看世界杯呀,笨蛋!”
“@#$%^&*%...”
確實(shí)如此,世界杯來(lái)了,球迷的節(jié)日也來(lái)了,估計(jì)很多ACMer也會(huì)拋開電腦,奔向電視了。
作為球迷,一定想看盡量多的完整的比賽,當(dāng)然,作為新時(shí)代的好青年,你一定還會(huì)看一些其它的節(jié)目,比如新聞聯(lián)播(永遠(yuǎn)不要忘記關(guān)心國(guó)家大事)、非常6+7、超級(jí)女生,以及王小丫的《開心辭典》等等,假設(shè)你已經(jīng)知道了所有你喜歡看的電視節(jié)目的轉(zhuǎn)播時(shí)間表,你會(huì)合理安排嗎?(目標(biāo)是能看盡量多的完整節(jié)目)
Input
輸入數(shù)據(jù)包含多個(gè)測(cè)試實(shí)例,每個(gè)測(cè)試實(shí)例的第一行只有一個(gè)整數(shù)n(n<=100),表示你喜歡看的節(jié)目的總數(shù),然后是n行數(shù)據(jù),每行包括兩個(gè)數(shù)據(jù)Ti_s,Ti_e (1<=i<=n),分別表示第i個(gè)節(jié)目的開始和結(jié)束時(shí)間,為了簡(jiǎn)化問(wèn)題,每個(gè)時(shí)間都用一個(gè)正整數(shù)表示。n=0表示輸入結(jié)束,不做處理。
Output
對(duì)于每個(gè)測(cè)試實(shí)例,輸出能完整看到的電視節(jié)目的個(gè)數(shù),每個(gè)測(cè)試實(shí)例的輸出占一行。
Sample Input
12
1 3
3 4
0 7
3 8
15 19
15 20
10 15
8 18
6 12
5 10
4 14
2 9
0
Sample Output
5
代碼:package acm題目;
import java.io.BufferedInputStream;
import java.util.Scanner;
public class acm2037 {
public static void main(String[] args) {
Scanner sc=new Scanner(new BufferedInputStream(System.in));
while(sc.hasNext()) {
int n=sc.nextInt();
if(n==0) return;
int []s=new int[n];
int []e=new int[n];
int count=1;
for(int i=0;i<n;i++) {
s[i]=sc.nextInt();
e[i]=sc.nextInt();
}
for(int i=0;i<n;++i) {
for(int j=i;j<n;++j) {
if(e[i]>e[j]) {
int temp=e[i];
e[i]=e[j];
e[j]=temp;
temp=s[i];
s[i]=s[j];
s[j]=temp;
}
}
}
int b=e[0];
for(int i=0;i<n;i++) {
if(s[i]>=b) {
count++;
b=e[i];
}
}
System.out.println(count);
}
}
}
題目三:
親和數(shù)
Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 66560????Accepted Submission(s): 40313
Problem Description
古希臘數(shù)學(xué)家畢達(dá)哥拉斯在自然數(shù)研究中發(fā)現(xiàn),220的所有真約數(shù)(即不是自身的約數(shù))之和為:?
1+2+4+5+10+11+20+22+44+55+110=284。?
而284的所有真約數(shù)為1、2、4、71、 142,加起來(lái)恰好為220。人們對(duì)這樣的數(shù)感到很驚奇,并稱之為親和數(shù)。一般地講,如果兩個(gè)數(shù)中任何一個(gè)數(shù)都是另一個(gè)數(shù)的真約數(shù)之和,則這兩個(gè)數(shù)就是親和數(shù)。?
你的任務(wù)就編寫一個(gè)程序,判斷給定的兩個(gè)數(shù)是否是親和數(shù)
Input
輸入數(shù)據(jù)第一行包含一個(gè)數(shù)M,接下有M行,每行一個(gè)實(shí)例,包含兩個(gè)整數(shù)A,B; 其中 0 <= A,B <= 600000 ;
Output
對(duì)于每個(gè)測(cè)試實(shí)例,如果A和B是親和數(shù)的話輸出YES,否則輸出NO。
Sample Input
2
220 284
100 200
Sample Output
YES
NO
代碼:package acm題目;
import java.util.Scanner;
public class acm2040 {
public static void main(String[] args) {
? Scanner sc=new Scanner(System.in);
? while(sc.hasNext()) {
? int M=sc.nextInt();
? int A,B;
? for(int i=0;i<M;i++) {
? ? A=sc.nextInt();
? ? B=sc.nextInt();
? ? int sum=0;
? for(int j=1;j<A;j++) {
? ? if(A%j==0) {
? ? sum+=j;
? ? }
? }
? if(sum==B)System.out.println("YES");
? else System.out.println("NO");
? }
? }
}
}
題目四
Problem Description
有一樓梯共M級(jí),剛開始時(shí)你在第一級(jí),若每次只能跨上一級(jí)或二級(jí),要走上第M級(jí),共有多少種走法?
Input
輸入數(shù)據(jù)首先包含一個(gè)整數(shù)N,表示測(cè)試實(shí)例的個(gè)數(shù),然后是N行數(shù)據(jù),每行包含一個(gè)整數(shù)M(1<=M<=40),表示樓梯的級(jí)數(shù)。
Output
對(duì)于每個(gè)測(cè)試實(shí)例,請(qǐng)輸出不同走法的數(shù)量
Sample Input
2
2
3
Sample Output
1
2
代碼:
package acm題目;
import java.util.Scanner;
public class acm2041 {
static int fun(int n) {
? if(n==2||n==3)
? return (n-1);
? return fun(n-1)+fun(n-2);
}
public static void main(String[] args) {
? Scanner sc=new Scanner(System.in);
? while(sc.hasNext()) {
? int N=sc.nextInt();
? int s[]=new int[N];
? for(int i=0;i<N;i++) {
? ? s[i]=sc.nextInt();
? }
? for(int j=0;j<N;j++) {
? ? System.out.println(fun(s[j]));
? }
? }
}
}
題目五
Problem Description
有一只經(jīng)過(guò)訓(xùn)練的蜜蜂只能爬向右側(cè)相鄰的蜂房,不能反向爬行。請(qǐng)編程計(jì)算蜜蜂從蜂房a爬到蜂房b的可能路線數(shù)。
其中,蜂房的結(jié)構(gòu)如下所示。

Input
輸入數(shù)據(jù)的第一行是一個(gè)整數(shù)N,表示測(cè)試實(shí)例的個(gè)數(shù),然后是N 行數(shù)據(jù),每行包含兩個(gè)整數(shù)a和b(0<a<b<50)。
Output
對(duì)于每個(gè)測(cè)試實(shí)例,請(qǐng)輸出蜜蜂從蜂房a爬到蜂房b的可能路線數(shù),每個(gè)實(shí)例的輸出占一行。
Sample Input
2
1 2
3 6
Sample Output
1
3
代碼:package acm題目;
import java.util.Scanner;
public class acm2044 {
public static void? main(String[] args) {
? Scanner sc=new Scanner(System.in);
? while(sc.hasNext()) {
? int N=sc.nextInt();
? long s[]=new long[50];
? s[0]=s[1]=1;
? while(N--!=0){
? ? int a=sc.nextInt();
? ? int b=sc.nextInt();
? ? int n=(b-a);
? ? for(int k=2;k<50;k++) {
? ? s[k]=(s[k-2]+s[k-1]);
? ? }
? ? System.out.println(s[n]);
? }
? }
? }
}
題目六
Problem Description
Give you the width and height of the rectangle,darw it.
Input
Input contains a number of test cases.For each case ,there are two numbers n and m (0 < n,m < 75)indicate the width and height of the rectangle.Iuput ends of EOF.
Output
For each case,you should draw a rectangle with the width and height giving in the input.
after each case, you should a blank line.
Sample Input
3 2
Sample Output
+---+
|? ? ? |
|? ? ? ?|
+---+
代碼:
package acm題目;
import java.util.Scanner;
public class acm2052 {
public static void main(String[] args) {
? Scanner sc=new Scanner(System.in);
? while(sc.hasNext()) {
? int m=sc.nextInt();
? int n=sc.nextInt();
? for(int i=0;i<n+2;i++) {
? ? for(int j=0;j<m+2;j++) {
? ? if(i==0&&j==0||j==0&&i==(n+1)||i==0&&j==(m+1)||i==(n+1)&&j==(m+1)) {
? ? ? System.out.print("+");
? ? }
? ? else if((i==0&&j!=0&&j!=m+1)||(i==n+1&&j!=0&&j!=m+1)) {
? ? ? System.out.print("-");
? ? }
? ? else if(i!=0&&i!=n+1&&j==0||i!=0&&i!=n+1&&j==m+1) {
? ? ? System.out.print("|");
? ? }
? ? else System.out.print(" ");
? ? }
? ? System.out.println();
? }
? System.out.println();
? }
}
}
題目七
Problem Description
Give you a number on base ten,you should output it on base two.(0 < n < 1000)
Input
For each case there is a postive number n on base ten, end of file.
Output
For each case output a number on base two.
Sample Input
1
2
3
Sample Output
1
10
11
代碼:package acm題目;
import java.util.Scanner;
public class acm2051 {
public static void main(String[] args) {
? Scanner sc=new Scanner(System.in);
? while(sc.hasNext()) {
? int s=sc.nextInt();
? int s1=s;
? int []a=new int[1000];
? int count=0;
? while(s!=0) {
? ? count++;
? ? s=s/2;
? }
? for(int i=0;i<count;i++) {
? ? a[i]=s1%2;
? ? s1=s1/2;
? }
? for(int i=count-1;i>=0;i--) {
? ? System.out.print(a[i]);
? }
? System.out.println("");
? }
}
}
打卡題目
題目描述:翻轉(zhuǎn)字符串并實(shí)現(xiàn)單調(diào)遞增,只含有0 1兩個(gè)數(shù)字
代碼:
package acm題目;
import java.util.Scanner;
public class acm課程作業(yè) {
public static int min(String S) {
? ? ? ? char c[]=S.toCharArray();
? ? ? ? int min=99999;int zero=0;
? ? ? ? for(int i=0;i<c.length;i++) {
? ? ? ? if(c[i]-'1'!=0) {
? ? ? ? ? zero++;
? ? ? ? }
? ? ? ? }
? ? ? ? min=zero;
? ? ? ? for(int i=0;i<c.length;i++) {
? ? ? ? if(c[i]=='0') {
? ? ? ? zero--;
? ? ? ? ? min=Math.min(zero, min);
? ? ? ? }else {
? ? ? ? ? zero++;
? ? ? ? }
? ? ? ? }
? ? ? ? return min;
? ? ? }
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while(sc.hasNext()) {
String a=sc.nextLine();
System.out.println(min(a));
}
}
}