锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲第一永久AV网站久久精品男人的天堂AV
,热久久国产欧美一区二区精品,怡红院日本一道日本久久
http://www.shnenglu.com/Icho/category/14622.htmlSome birds aren`t meant to be caged, their feathers are just too bright... ...zh-cnThu, 19 Aug 2010 17:06:07 GMTThu, 19 Aug 2010 17:06:07 GMT60SGU 118 Digital Roothttp://www.shnenglu.com/Icho/archive/2010/08/19/123977.htmlBrianBrianThu, 19 Aug 2010 07:35:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/19/123977.htmlhttp://www.shnenglu.com/Icho/comments/123977.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/19/123977.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123977.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123977.html杈撳叆鍖呭惈K涓祴璇曟牱渚嬨傝緭鍏ョ涓琛屼細緇欏嚭 K (1<=K<=5)銆傛瘡涓祴璇曟牱渚嬪崰涓琛屻傝繖涓琛岀殑絎竴涓暟鏄竴涓鏁存暟N (N<=1000)銆?鎺ョ潃鏄疦涓潪璐熸暣鏁?(搴忓垪 A)銆?鍧囦笉瓚呰繃109銆?/p>
鏁版牴(鐧懼害鐭ラ亾): http://zhidao.baidu.com/question/29789035.html 瀵逛簬姹備綑鏁扮殑闂鏄垜涓寮濮嬪氨蹇界暐浜嗙殑鍦版柟錛屽悗鏉ョ湅浜咹PF鐨勫崥瀹紝鎵嶇煡閬撴湁榪欐牱鐨勬妧宸? (A+B)mod C = (A mod C) + (B mod C) (AB) mod C = (A mod C) × (B mod C)
]]>SGU 111 Very simple problemhttp://www.shnenglu.com/Icho/archive/2010/08/19/123969.htmlBrianBrianThu, 19 Aug 2010 06:36:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/19/123969.htmlhttp://www.shnenglu.com/Icho/comments/123969.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/19/123969.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123969.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123969.html甯屾湜澶х墰浠寚鏁?/span>錛?br>
]]>SGU 107 987654321 problemhttp://www.shnenglu.com/Icho/archive/2010/08/17/123698.htmlBrianBrianTue, 17 Aug 2010 05:27:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/17/123698.htmlhttp://www.shnenglu.com/Icho/comments/123698.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/17/123698.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123698.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123698.htmlFor given number N you must output amount of N-digit numbers, such, that last digits of their square is equal to 987654321.
Input
Input contains integer number N (1<=N<=106) 棣栧厛鎯沖埌鐨勬槸鏋氫婦錛屾垜紜疄涔熻繖涔堝仛浜嗭紝5~8鏃犳灉錛屽浜?錛屾垜鐨?5騫存柟姝?Pentium M 涓婅窇浜嗚凍瓚?鍒嗗崐閽熶箣涔咃紝鎴戜竴寮濮嬭繕浠ヤ負姝誨驚鐜簡錛屽悗鏉ュ嚭鏉ュ叓涓粨鏋滐紝涔熷幓緗戜笂鏍稿浜嗕竴涓嬶紝紜疄婊¤凍鐨勫彧鏈夎繖鍏釜: 111111111 119357639 380642361 388888889 611111111 619357639 880642361 888888889 鎴戞病鏈夊榪囨暟璁猴紝鎵懼埌涓綃囧崥鏂囷紝瀵逛簬鏁拌瑙f硶璁茬殑榪樼畻娓呮錛屼笉榪囩敤pascal鍐欏氨錛屾垜鑷繁鐢–鍐欎簡涓涓嬶紝絎笁嬈C浜嗐傚崥鏂囬摼鎺ュ涓嬶細http://blog.csdn.net/Skyprophet/archive/2009/10/05/4634801.aspx
#include <stdio.h> int main() { int N,i=0; scanf("%d",&N); if (N<=8) printf("0\n"); elseif (N==9) printf("8\n"); else { printf("72"); for (; i<N-10; i++) printf("0"); printf("\n"); } return0; }
]]>SGU 105 Div 3http://www.shnenglu.com/Icho/archive/2010/08/17/123697.htmlBrianBrianTue, 17 Aug 2010 05:26:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/17/123697.htmlhttp://www.shnenglu.com/Icho/comments/123697.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/17/123697.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123697.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123697.html
There is sequence 1, 12, 123, 1234, ..., 12345678910, ... . Given first N elements of that sequence. You must determine amount of numbers in it that are divisible by 3. (鎵懼嚭榪欎釜鏁板垪1-N鍙峰厓绱犱腑鑳借3鏁撮櫎鐨勬湁澶氬皯涓?
]]>SGU 102 Coprimeshttp://www.shnenglu.com/Icho/archive/2010/08/17/123696.htmlBrianBrianTue, 17 Aug 2010 05:24:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/17/123696.htmlhttp://www.shnenglu.com/Icho/comments/123696.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/17/123696.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123696.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123696.html4) 錛屾壘鍑烘墍鏈変笉澶т簬N涓斾笌N浜掕川鐨勬鏁存暟涓暟銆?br>涓や釜姝f暣鏁癆鍜孊浜掕川鐨勬剰鎬濇槸瀹冧滑鐨勬渶澶у叕綰︽暟鏄?銆傜幇鐪嬩竴涓嬬櫨搴︾櫨縐戜笂鍏充簬璐ㄦ暟鐨勫畾涔夊惂銆?br>褰撴垜閲囩敤鐩存帴鏁扮殑鍔炴硶AC鍚庯紝鎴戝彂鐜?font color=#3366ff>璺熻川鏁板畬鍏ㄦ病鏈夊叧緋匯?/font>
#include<stdio.h>
int gcd(int m,int n) // greatest common divisor { int r=m%n; while(r) // 杈楄漿鐩擱櫎娉曪紝TAOCP鐨勭涓涓畻娉?/span> { m=n; n=r; r=m%n; } return n; }
int main() { int N,c=0,i=1; // must start with 1 ! scanf("%d",&N); for (; i<=N; i++) if (gcd(N,i)==1) // question hint c++; printf("%d",c); return0; } // 102 .C Accepted 0 ms 0 kb
]]>SGU 113 Nearly prime numbershttp://www.shnenglu.com/Icho/archive/2010/08/17/123695.htmlBrianBrianTue, 17 Aug 2010 05:23:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/17/123695.htmlhttp://www.shnenglu.com/Icho/comments/123695.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/17/123695.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123695.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123695.html
Nearly prime number is an integer positive number for which it is possible to find such primes P1 and P2 that given number is equal to P1*P2. There is given a sequence on N integer positive numbers, you are to write a program that prints “Yes” if given number is nearly prime and “No” otherwise.
Input
Input file consists of N+1 numbers. First is positive integer N (1£N£10). Next N numbers followed by N. Each number is not greater than 109. All numbers separated by whitespace(s).
Output
Write a line in output file for each number of given sequence. Write “Yes” in it if given number is nearly prime and “No” in other case. 涓嶇敤綆early prime numbers 鍒板簳鏄釜浠涔堟暟錛屾諱箣鏄袱涓川鏁扮殑涔樼Н灝卞浜嗐傛灇涓劇殑鑼冨洿: 2 ~ 32000 (104.5 ) 鎴戠殑鎬濊礬鏄? 棣栧厛鎶?~32000涔嬮棿鐨勬墍鏈夌礌鏁伴兘瀛樻斁鍦ㄤ竴涓暟緇勯噷錛岀劧鍚庡綋浣犺緭鍏ヤ竴涓暟鎹椂錛屽厛璁╁叾閫愪竴妯¢櫎榪欎釜鏁扮粍閲岀殑绱犳暟錛屼竴鏃︽ā闄ょ粨鏋滀負0錛屽垯璁$畻鍑轟粬浠殑鍟嗭紝鍐嶅垽鏂晢鏄惁涔熶負绱犳暟銆?strong>娉ㄦ剰鏁版嵁鏄袱涓暟鐨勫鉤鏂圭殑澶勭悊
#include <stdio.h> #include <math.h> int prime[30000],M=0; int isP(int n) //鍒ゆ柇鏄惁涓虹礌鏁?闈炲父綺劇‘鑰岄珮鏁?/span> { int i=2,t=sqrt(n); if ((n !=2&&!(n %2)) || (n !=3&&!(n %3)) || (n !=5&&!(n %5)) || (n !=7&&!(n %7))) return0; for (; i<=t; i++) if (n%i ==0) return0; return1; } int isNP(int n) { int i=0,t=sqrt(n),r; for (; prime[i]<=t; i++) // 騫蟲柟鍦ㄦ澶勭悊 { if (n%prime[i] ==0) // 妯¢櫎璇曞晢 { r=n/prime[i]; // 姹傚晢 if (isP(r)) return1; } } return0; } int main() { int i=3,N,m; for (prime[M++]=2; i<32000; i+=2) if (isP(i)) prime[M++]=i; scanf("%d",&N); while (N--) { scanf("%d",&m); if (m==6) printf("Yes\n"); // 紼嬪簭涓敮涓鏈В鍐崇殑闂,鏈涘悇璺ぇ鐗涙寚鏁? else printf("%s\n",isNP(m) ?"Yes":"No"); } return0; }
]]>SGU 112 a^b-b^a (Java Edition)http://www.shnenglu.com/Icho/archive/2010/08/17/123694.htmlBrianBrianTue, 17 Aug 2010 05:21:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/17/123694.htmlhttp://www.shnenglu.com/Icho/comments/123694.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/17/123694.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123694.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123694.htmlYou are given natural numbers a and b. Find ab-ba.
import java.math.*; import java.util.*; publicclass Solution { publicstaticvoid main(String[] args) { Scanner in =new Scanner(System.in); int a = in.nextInt(); int b = in.nextInt(); BigInteger A=BigInteger.valueOf(a); BigInteger B=BigInteger.valueOf(b); // A^B BigInteger rA=BigInteger.valueOf(a); BigInteger rB=BigInteger.valueOf(b); // store the result after computing for(int i=1; i<b; i++) // just b-1 times rA=rA.multiply(A); for(int i=1; i<a; i++) rB=rB.multiply(B); System.out.println(rA.subtract(rB)); // sub } }
闄勩奀ore Java I銆嬮噷鍏充簬 澶ф暟鐨勭畝鍗曚粙緇嶏紝璁茬殑綆楁瘮杈冩竻鏅扮殑浜嗭細 Big Numbers If the precision of the basic integer and floating-point types is not sufficient, you can turn to a couple of handy classes in the java.math package: BigInteger and BigDecimal. These are classes for manipulating numbers with an arbitrarily long sequence of digits. The BigInteger class implements arbitrary precision integer arithmetic, and BigDecimal does the same for floating-point numbers. Use the static valueOf method to turn an ordinary number into a big number: BigInteger a = BigInteger.valueOf(100); Unfortunately, you cannot use the familiar mathematical operators such as + and * to combine big numbers. Instead, you must use methods such as add and multiply in the big number classes. BigInteger c = a.add(b); // c = a + b BigInteger d = c.multiply(b.add(BigInteger.valueOf(2))); // d = c * (b + 2) C++ NOTE: Unlike C++, Java has no programmable operator overloading. There was no way for the programmer of the BigInteger class to redefine the + and * operators to give the add and multiply operations of the BigInteger classes. The language designers did overload the + operator to denote concatenation of strings. They chose not to overload other operators, and they did not give Java programmers the opportunity to overload operators in their own classes. Listing 3–6 shows a modification of the lottery odds program of Listing 3–5, updated to work with big numbers. For example, if you are invited to participate in a lottery in which you need to pick 60 numbers out of a possible 490 numbers, then this program will tell you that your odds are 1 in 7163958434619955574151162225400929334117176 12789263493493351 013459481104668848. Good luck! The program in Listing 3–5 computed the statement lotteryOdds = lotteryOdds * (n - i + 1) / i; When big numbers are used, the equivalent statement becomes lotteryOdds = lotteryOdds.multiply(BigInteger.valueOf(n - i + 1)).divide(BigInteger.valueOf(i)); Listing 3–6 BigIntegerTest.java 1. import java.math.*; 2. import java.util.*; 3. 4. /** 5. * This program uses big numbers to compute the odds of winning the grand prize in a lottery. 6. * @version 1.20 2004-02-10 7. * @author Cay Horstmann 8. */ 9. public class BigIntegerTest 10. { 11. public static void main(String[] args) 12. { 13. Scanner in = new Scanner(System.in); 14. 15. System.out.print("How many numbers do you need to draw? "); 16. int k = in.nextInt(); 17. 18. System.out.print("What is the highest number you can draw? "); 19. int n = in.nextInt(); 20. 21. /* 22. * compute binomial coefficient n*(n-1)*(n-2)*...*(n-k+1)/(1*2*3*...*k) 23. */ 24. 25. BigInteger lotteryOdds = BigInteger.valueOf(1); 26. 27. for (int i = 1; i <= k; i++) 28. lotteryOdds = lotteryOdds.multiply(BigInteger.valueOf(n - i + 1)).divide( 29. BigInteger.valueOf(i)); 30. 31. System.out.println("Your odds are 1 in " + lotteryOdds + ". Good luck!"); 32. } 33. }
java.math.BigInteger
? BigInteger add(BigInteger other) ? BigInteger subtract(BigInteger other) ? BigInteger multiply(BigInteger other) ? BigInteger divide(BigInteger other) ? BigInteger mod(BigInteger other) returns the sum, difference, product, quotient, and remainder of this big integer and other. ? int compareTo(BigInteger other) returns 0 if this big integer equals other, a negative result if this big integer is less than other, and a positive result otherwise. ? static BigInteger valueOf(long x) returns a big integer whose value equals x. ? BigDecimal add(BigDecimal other) ? BigDecimal subtract(BigDecimal other) ? BigDecimal multiply(BigDecimal other) ? BigDecimal divide(BigDecimal other, RoundingMode mode) 5.0 returns the sum, difference, product, or quotient of this big decimal and other. To compute the quotient, you must supply a rounding mode. The mode RoundingMode.HALF_UP is the rounding mode that you learned in school (i.e., round down digits 0 . . . 4, round up digits 5 . . . 9). It is appropriate for routine calculations. See the API documentation for other rounding modes. ? int compareTo(BigDecimal other) returns 0 if this big decimal equals other, a negative result if this big decimal is less than other, and a positive result otherwise. ? static BigDecimal valueOf(long x) ? static BigDecimal valueOf(long x, int scale) returns a big decimal whose value equals x or x /10scale.