锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲欧洲精品成人久久奇米网 ,精品多毛少妇人妻AV免费久久 ,亚洲中文精品久久久久久不卡 http://www.shnenglu.com/Yuan/category/16255.htmlzh-cnSun, 07 Aug 2011 15:29:07 GMTSun, 07 Aug 2011 15:29:07 GMT60hdu 3826http://www.shnenglu.com/Yuan/archive/2011/08/07/152690.html_Yuan_YuanSat, 06 Aug 2011 18:40:00 GMThttp://www.shnenglu.com/Yuan/archive/2011/08/07/152690.htmlhttp://www.shnenglu.com/Yuan/comments/152690.htmlhttp://www.shnenglu.com/Yuan/archive/2011/08/07/152690.html#Feedback0http://www.shnenglu.com/Yuan/comments/commentRss/152690.htmlhttp://www.shnenglu.com/Yuan/services/trackbacks/152690.html/*
    闂畁<=10^18鏄惁鑳借涓涓暟鐨勫鉤鏂規(guī)暣闄?br />    灝唍鍒嗚В涓猴細(xì)p1p2pk  鍏朵腑pi涓虹礌鏁幫紝涓攑i<=pi+1錛堣繖閲屽彲浠ョ瓑浜庯級
    鑻鑳借涓涓暟鐨勫鉤鏂規(guī)暣闄わ紝瀹冭偗瀹氳兘琚竴涓礌鍥犲瓙鐨勫鉤鏂筽^2鏁撮櫎錛屾垜浠壘鍒版渶灝忕殑榪欎釜p鍗沖彲  ~~~
    1.濡傛灉p涓嶆槸鏈鍚庣殑绱犲洜瀛愶紝鍦╬涔嬪悗鐨勭礌鏁皃i>=p錛岃繖鏃跺氨鏈塶>=p^3浜嗭紝
       鍗硃<=n^(1/3)錛屾墍浠ユ灇涓緉^(1/3)鍐呯殑绱犳暟鐪嬫槸鍚^2|n鍗沖彲錛岃宯^(1/3)<=10^6
    2.濡傛灉p鏄渶鍚庣殑绱犲洜瀛愶紝鎵浠鐨勫艦寮忓氨鏄痯1p2p'p^2錛岃宲'<=p錛屾墍浠'^3<=n錛宲'<=n^(1/3)
       鎵浠ュ彲浠ュ厛灝唍鐨勮繖浜涚礌鍥犲瓙p1,p2,,p'緇欏幓鎺夛紝p'<=n^(1/3)錛屾墍浠ョ敤n^(1/3)鍐呯殑绱犳暟鍘婚櫎鍗沖彲
       鏈鍚庡彧鍓╀笅n'=p^2錛岄氳繃鍒ゆ柇涓涓暟鏄惁涓哄畬鍏ㄥ鉤鏂規(guī)暟鍗沖彲

    綆楁硶灝辨槸棰勫鐞?0^6鍐呯殑绱犳暟錛岀敤榪欎簺绱犳暟鍘婚櫎n錛屽彂鐜版湁p^2鑳芥暣闄ょ殑return鍗沖彲
    鍚﹀垯鍒ゆ柇鍓╀笅鐨勮繖涓猲'鏄惁涓哄畬鍏ㄥ鉤鏂規(guī)暟錛屾垜鏄敤浜屽垎鍒ゆ柇鐨勶紝鍔犱簡double澶勭悊long long 婧㈠嚭
*/

#include
<cstdio>
#include
<cstring>
#include
<algorithm>
#include
<vector>
#include
<queue>
#include
<string>
#include
<iostream>
#include
<cassert>

using namespace std;

bool isp[1000010];
int pr[300000], pn;

void init()
{
    
for (int p = 2; p <= 1000000; p++{
        
if (!isp[p]) {
            pr[pn
++= p;
            
for (long long j = (long long)p*p; j <= 1000000; j+= p) {
                isp[j] 
= 1;
            }

        }

    }

}


// n = p1p2pk

bool chk(long long n)
{
    
for (int i = 0; i < pn && pr[i] <= n; i++{
        
if (n % pr[i] == 0{
            n 
/= pr[i];
            
if (n%pr[i] == 0return 0;
        }

    }

    
if (n == 1{
        
return 1;
    }

    
long long left = 1, right = n;
    
while (left <= right) {
        
long long mid = (left + right) / 2;
        
if ((double)mid*mid > n) right = mid - 1;//double !!
        else left = mid+1;
    }

    
return right*right != n;
}



int main()
{
    
//freopen("in.txt", "r", stdin);
    init();
    
int T, t = 1;
    
for (scanf("%d"&T); T--; ) {
        printf(
"Case %d: ", t++);
        
long long n;
        scanf(
"%I64d"&n);
        puts(chk(n) 
? "Yes" : "No");
    }

    
return 0;
}



_Yuan 2011-08-07 02:40 鍙戣〃璇勮
]]>
CF17D 澶ф暣鏁板彇浣?/title><link>http://www.shnenglu.com/Yuan/archive/2011/05/03/145594.html</link><dc:creator>_Yuan</dc:creator><author>_Yuan</author><pubDate>Tue, 03 May 2011 11:14:00 GMT</pubDate><guid>http://www.shnenglu.com/Yuan/archive/2011/05/03/145594.html</guid><wfw:comment>http://www.shnenglu.com/Yuan/comments/145594.html</wfw:comment><comments>http://www.shnenglu.com/Yuan/archive/2011/05/03/145594.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/Yuan/comments/commentRss/145594.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Yuan/services/trackbacks/145594.html</trackback:ping><description><![CDATA[<div style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 13px; WORD-BREAK: break-all; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><img id=Codehighlighter1_0_327_Open_Image onclick="this.style.display='none'; Codehighlighter1_0_327_Open_Text.style.display='none'; Codehighlighter1_0_327_Closed_Image.style.display='inline'; Codehighlighter1_0_327_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_0_327_Closed_Image onclick="this.style.display='none'; Codehighlighter1_0_327_Closed_Text.style.display='none'; Codehighlighter1_0_327_Open_Image.style.display='inline'; Codehighlighter1_0_327_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif"><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_0_327_Closed_Text>/**/</span><span id=Codehighlighter1_0_327_Open_Text><span style="COLOR: #008000">/*</span><span style="COLOR: #008000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    灝辨槸姹?b-1)*b^(n-1) % c<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    鍏朵腑2<=b<=10^10^6 1<=n<=10^10^6,1<=c<=10^9<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    鐢↗ava楂樼簿搴︼紝瓚呮椂浜?img src="http://www.shnenglu.com/Images/dot.gif"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    鐪嬩簡鍒漢鐨勪唬鐮侊紝紲炲涓?img src="http://www.shnenglu.com/Images/dot.gif"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    b % c 鍏朵腑b鏄ぇ鏁存暟錛屽彲浠ヤ粠楂樹綅寰浣庝綅閫愪綅鎼?nbsp;r = (r*10+b[i])%c<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    鏇寸濂囩殑鏄紝a^b%c涓鏍蜂篃鍙互鐢ㄤ笂闈㈤偅鏍峰瓙鎼?br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    浣嗘槸灝變笉鏄痳*10鑰屾槸r^10, r = (r^10*(a^b[i]))%c<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    a^b[i]鍙互棰勫鐞嗭紝鍗砤^0,a^1,<img src="http://www.shnenglu.com/Images/dot.gif">,a^9<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    鏈夌敤鍏紡<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    a^b % c = a^b' %c<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    鍏朵腑b' = b>= p?b%p+p: b%p   p = phi(c)<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    榪欎釜鍏紡鎴愮珛涓嶉渶瑕?a,c)=1!!!<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif"></span><span style="COLOR: #008000">*/</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">cstring</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">map</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">algorithm</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">stack</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">queue</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">cmath</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">cstdlib</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">vector</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">cstdio</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">set</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">list</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">numeric</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">cassert</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">ctime</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif">#include</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">bitset</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> std;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> MAXN </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1000010</span><span style="COLOR: #000000">;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> b[MAXN], n[MAXN];<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000"> p[</span><span style="COLOR: #000000">10</span><span style="COLOR: #000000">];<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()<br><img id=Codehighlighter1_717_1480_Open_Image onclick="this.style.display='none'; Codehighlighter1_717_1480_Open_Text.style.display='none'; Codehighlighter1_717_1480_Closed_Image.style.display='inline'; Codehighlighter1_717_1480_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_717_1480_Closed_Image onclick="this.style.display='none'; Codehighlighter1_717_1480_Closed_Text.style.display='none'; Codehighlighter1_717_1480_Open_Image.style.display='inline'; Codehighlighter1_717_1480_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_717_1480_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_717_1480_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">#ifndef ONLINE_JUDGE<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">    freopen("in","r",stdin);</span><span style="COLOR: #008000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #0000ff">#endif</span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    <br><img id=Codehighlighter1_829_1467_Open_Image onclick="this.style.display='none'; Codehighlighter1_829_1467_Open_Text.style.display='none'; Codehighlighter1_829_1467_Closed_Image.style.display='inline'; Codehighlighter1_829_1467_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_829_1467_Closed_Image onclick="this.style.display='none'; Codehighlighter1_829_1467_Closed_Text.style.display='none'; Codehighlighter1_829_1467_Open_Image.style.display='inline'; Codehighlighter1_829_1467_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000"> c; </span><span style="COLOR: #000000">~</span><span style="COLOR: #000000">scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%s%s%I64d</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, b, n, </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">c); ) </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_829_1467_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_829_1467_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">(b-1)*b^(n-1) % c</span><span style="COLOR: #008000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> len </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> strlen(b);<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        </span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000"> r </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, left;<br><img id=Codehighlighter1_935_978_Open_Image onclick="this.style.display='none'; Codehighlighter1_935_978_Open_Text.style.display='none'; Codehighlighter1_935_978_Closed_Image.style.display='inline'; Codehighlighter1_935_978_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_935_978_Closed_Image onclick="this.style.display='none'; Codehighlighter1_935_978_Closed_Text.style.display='none'; Codehighlighter1_935_978_Open_Image.style.display='inline'; Codehighlighter1_935_978_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000"> len ; i </span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_935_978_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_935_978_Open_Text><span style="COLOR: #000000">{</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">r = b%c</span><span style="COLOR: #008000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">            r </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (r</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">10</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> b[i]</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">) </span><span style="COLOR: #000000">%</span><span style="COLOR: #000000"> c;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">        }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        left </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> (r</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">c</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">) </span><span style="COLOR: #000000">%</span><span style="COLOR: #000000"> c;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        <br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        len </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> strlen(n);<br><img id=Codehighlighter1_1063_1145_Open_Image onclick="this.style.display='none'; Codehighlighter1_1063_1145_Open_Text.style.display='none'; Codehighlighter1_1063_1145_Closed_Image.style.display='inline'; Codehighlighter1_1063_1145_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_1063_1145_Closed_Image onclick="this.style.display='none'; Codehighlighter1_1063_1145_Closed_Text.style.display='none'; Codehighlighter1_1063_1145_Open_Image.style.display='inline'; Codehighlighter1_1063_1145_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> len </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; i </span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000"> ; i</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000"> ) </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_1063_1145_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_1063_1145_Open_Text><span style="COLOR: #000000">{<br><img id=Codehighlighter1_1085_1106_Open_Image onclick="this.style.display='none'; Codehighlighter1_1085_1106_Open_Text.style.display='none'; Codehighlighter1_1085_1106_Closed_Image.style.display='inline'; Codehighlighter1_1085_1106_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_1085_1106_Closed_Image onclick="this.style.display='none'; Codehighlighter1_1085_1106_Closed_Text.style.display='none'; Codehighlighter1_1085_1106_Open_Image.style.display='inline'; Codehighlighter1_1085_1106_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">            </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (n[i] </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">) </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_1085_1106_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_1085_1106_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">                n[i] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br><img id=Codehighlighter1_1112_1141_Open_Image onclick="this.style.display='none'; Codehighlighter1_1112_1141_Open_Text.style.display='none'; Codehighlighter1_1112_1141_Closed_Image.style.display='inline'; Codehighlighter1_1112_1141_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_1112_1141_Closed_Image onclick="this.style.display='none'; Codehighlighter1_1112_1141_Closed_Text.style.display='none'; Codehighlighter1_1112_1141_Open_Image.style.display='inline'; Codehighlighter1_1112_1141_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">            }</span></span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"> </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_1112_1141_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_1112_1141_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">                n[i] </span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">                </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">            }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">        }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">p[i] = b^i % c;</span><span style="COLOR: #008000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">        p[</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br><img id=Codehighlighter1_1211_1241_Open_Image onclick="this.style.display='none'; Codehighlighter1_1211_1241_Open_Text.style.display='none'; Codehighlighter1_1211_1241_Closed_Image.style.display='inline'; Codehighlighter1_1211_1241_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_1211_1241_Closed_Image onclick="this.style.display='none'; Codehighlighter1_1211_1241_Closed_Text.style.display='none'; Codehighlighter1_1211_1241_Open_Image.style.display='inline'; Codehighlighter1_1211_1241_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"> ; i </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">10</span><span style="COLOR: #000000"> ; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_1211_1241_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_1211_1241_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">            p[i] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> p[i</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">] </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> r </span><span style="COLOR: #000000">%</span><span style="COLOR: #000000"> c;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">        }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        r </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br><img id=Codehighlighter1_1286_1405_Open_Image onclick="this.style.display='none'; Codehighlighter1_1286_1405_Open_Text.style.display='none'; Codehighlighter1_1286_1405_Closed_Image.style.display='inline'; Codehighlighter1_1286_1405_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_1286_1405_Closed_Image onclick="this.style.display='none'; Codehighlighter1_1286_1405_Closed_Text.style.display='none'; Codehighlighter1_1286_1405_Open_Image.style.display='inline'; Codehighlighter1_1286_1405_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000"> len ; i </span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_1286_1405_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_1286_1405_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">            </span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">long</span><span style="COLOR: #000000"> t </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> r;<br><img id=Codehighlighter1_1341_1375_Open_Image onclick="this.style.display='none'; Codehighlighter1_1341_1375_Open_Text.style.display='none'; Codehighlighter1_1341_1375_Closed_Image.style.display='inline'; Codehighlighter1_1341_1375_Closed_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_1341_1375_Closed_Image onclick="this.style.display='none'; Codehighlighter1_1341_1375_Closed_Text.style.display='none'; Codehighlighter1_1341_1375_Open_Image.style.display='inline'; Codehighlighter1_1341_1375_Open_Text.style.display='inline';" align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">            </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> j </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"> ;j </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">10</span><span style="COLOR: #000000"> ; j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_1341_1375_Closed_Text><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_1341_1375_Open_Text><span style="COLOR: #000000">{</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">b^(l*10)</span><span style="COLOR: #008000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">                r </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> r </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> t </span><span style="COLOR: #000000">%</span><span style="COLOR: #000000"> c;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">            }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">            r </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> r</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">p[n[i]</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">] </span><span style="COLOR: #000000">%</span><span style="COLOR: #000000"> c;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">        }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        r </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> left </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> r </span><span style="COLOR: #000000">%</span><span style="COLOR: #000000"> c;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%I64d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, r </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">?</span><span style="COLOR: #000000"> c : r);<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span></div> <img src ="http://www.shnenglu.com/Yuan/aggbug/145594.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Yuan/" target="_blank">_Yuan</a> 2011-05-03 19:14 <a href="http://www.shnenglu.com/Yuan/archive/2011/05/03/145594.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>poj 1845http://www.shnenglu.com/Yuan/archive/2011/03/14/141825.html_Yuan_YuanMon, 14 Mar 2011 14:51:00 GMThttp://www.shnenglu.com/Yuan/archive/2011/03/14/141825.htmlhttp://www.shnenglu.com/Yuan/comments/141825.htmlhttp://www.shnenglu.com/Yuan/archive/2011/03/14/141825.html#Feedback0http://www.shnenglu.com/Yuan/comments/commentRss/141825.htmlhttp://www.shnenglu.com/Yuan/services/trackbacks/141825.html闃呰鍏ㄦ枃

_Yuan 2011-03-14 22:51 鍙戣〃璇勮
]]>
hdu 3187 嬈ф媺鍑芥暟 鏋氫婦p-1 鈽呪槄鈽呪槄http://www.shnenglu.com/Yuan/archive/2011/03/14/141776.html_Yuan_YuanMon, 14 Mar 2011 03:55:00 GMThttp://www.shnenglu.com/Yuan/archive/2011/03/14/141776.htmlhttp://www.shnenglu.com/Yuan/comments/141776.htmlhttp://www.shnenglu.com/Yuan/archive/2011/03/14/141776.html#Feedback0http://www.shnenglu.com/Yuan/comments/commentRss/141776.htmlhttp://www.shnenglu.com/Yuan/services/trackbacks/141776.html/*
    緇欏嚭n錛岄棶婊¤凍phi(k) = n鐨刱鐨勪釜鏁幫紝鍏朵腑k鐨勭礌鍥犲瓙涓暟<=3    n<2^31
    嬈ф媺鍑芥暟
    phi(k) = k(1-1/p1)(1-1/p2)(1-1/p3)
             = (p1-1)p1^x*(p2-1)p2^y*(p3-1)p3^z
     phi(1) = 1

    姣旇禌鏃舵墦綆楃瓫绱犳暟錛堢瓫鍒皊qrt(2^31)錛夛紝鏋氫婦p1,p2,p3
    鏈夐棶棰樼殑錛屾瘮濡?nbsp;n = (3-1) * p
    褰搉寰堝ぇ鏃訛紝榪欐牱p灝辨槸涓涓緢澶х殑鏁頒簡錛岃岀礌鏁拌〃娌℃湁錛屽氨鏋氫婦涓嶅埌浜嗭紒

    闂簡ACOrz錛屼粬鐨勪唬鐮佸緢紲炲鍛
    鍥犱負(fù)n = (p1-1)p1^x*(p2-1)p2^y*(p3-1)p3^z
    鐢╯qrt(n)鏋氫婦(pi-1)
        if(n%(pi-1) && isPrime(pi))鍔犲叆pi
    鐒跺悗灝眃fs鍑烘渶澶?涓暟錛岃 (p1-1)p1^x*(p2-1)p2^y*(p3-1)p3^z = n
    
    娉ㄦ剰鐨勬槸phi(1) = 1
    鎵浠=1鏃?婊¤凍鏉′歡鐨勬湁2涓紝鍗砶=1,2
    
    ACOrz鐨勪唬鐮佸緢綆媧侊紝涓嬮潰鏄垜鎸夌収鎴戠殑椋庢牸妯′豢浠栧啓鐨?br>    娉ㄦ剰鏋氫婦鐨勬槸(pi - 1)錛屼笉鏄痭鐨勭礌鍥犲瓙 錛侊紒錛?br>
*/

#include
<iostream>
#include
<cstring>
#include
<map>
#include
<algorithm>
#include
<stack>
#include
<queue>
#include
<cmath>
#include
<string>
#include
<cstdlib>
#include
<vector>
#include
<cstdio>
#include
<set>
#include
<list>
#include
<numeric>
#include
<cassert>
#include
<ctime>

using namespace std;

vector
<int> prime;
int ans;

bool isPrime(int n){
    
for(int p = 2; p <= n/p ; p++){
        
if(n % p == 0){
            
return false;
        }

    }

    
return true;
}


void dfs(int next, vector<int> with, int n){
    
int nn = n;
    
bool can = true;
    
for(vector<int>::iterator it = with.begin() ; it != with.end() ; it++){//媯鏌ュ悎娉曟?/span>
        if(n % (*it-1== 0)    {
            n 
/= (*it-1);
        }
else {
            can 
= false;
            
break;
        }

    }

    
if(can){
        
//with鍙互涓虹┖錛侊紒錛?/span>
        for(vector<int>::iterator it = with.begin() ; it != with.end() ; it++){
            
while(n % *it == 0){
                n 
/= *it;
            }

        }

        
if(n == 1)ans++;//鐗規(guī)畩鎯呭喌鏄痺ith涓虹┖錛屼絾鍘熷鐨刵涓?
        if(with.size() == 3){
            
return;
        }

        
for(int i = next ; i < prime.size(); i++){//鎵╁睍
            with.push_back(prime[i]);
            dfs(i
+1, with, nn);
            with.pop_back();
        }

    }
    
}


int main()
{
#ifndef ONLINE_JUDGE
    
//freopen("in","r",stdin);
#endif

    
for(int n; ~scanf("%d"&n); ){
        prime.clear();
        
for(int i = 1 ; i <= n / i; i++){
            
if(n % i == 0){
                
if(isPrime(i+1)){
                    prime.push_back(i
+1);
                }

                
if(n/!= i && isPrime(n/i+1)){
                    prime.push_back(n
/i+1);
                }

            }

        }

        ans 
= 0;
        dfs(
0, vector<int>(), n);
        printf(
"%d\n", ans);
    }

    
return 0;
}


_Yuan 2011-03-14 11:55 鍙戣〃璇勮
]]>
CodeForces 60D 鍕捐偂鏁板叕寮?鏋氫婦鐢熸垚http://www.shnenglu.com/Yuan/archive/2011/02/21/140358.html_Yuan_YuanMon, 21 Feb 2011 03:15:00 GMThttp://www.shnenglu.com/Yuan/archive/2011/02/21/140358.htmlhttp://www.shnenglu.com/Yuan/comments/140358.htmlhttp://www.shnenglu.com/Yuan/archive/2011/02/21/140358.html#Feedback0http://www.shnenglu.com/Yuan/comments/commentRss/140358.htmlhttp://www.shnenglu.com/Yuan/services/trackbacks/140358.html/*
    n<=10^6涓偣錛屾瘡涓偣鏈夋潈鍊糰[i]<=10^7 鍚勪笉鐩稿悓
    鑻ュ瓨鍦ㄤ竴涓暟x錛屼嬌寰梐[i],a[j],x   is a beautiful triple
    鍗砤^2 + b^2 = c^2   a,b,c浜掔礌
    鍒檌鍙互浼犳挱laugh鍒癹
    闂渶灝戦渶瑕侀渶瑕佽澶氬皯涓《鐐硅嚜琛宭augh錛岀劧鍚庝紶鎾埌鍏ㄩ儴鐨勯《鐐?br>
    鐪嬩簡瑙i鎶ュ憡鐨?br>    騫舵煡闆嗗仛
    浣嗗浣曞垽鏂璪eautiful triple 涓や袱鍒ゆ柇O(n^2)浼?xì)瓒呮?br>
    鏈変釜鎬ц川錛氬浜庢弧瓚砤^2 + b^2 = c^2鐨勬暟錛屽彲鐢ㄥ嬀鑲℃暟鍏紡鐢熸垚錛?br>    (x^2-y^2 , 2xy , x^2+y^2)  x>y
    璇ュ叕寮忚兘鐢熸垚鎵鏈夌殑绱犲嬀鑲℃暟錛堜簰璐級錛岄渶1濂?鍋?nbsp;錛屼笖gcd(x,y) = 1
    涔熻兘鐢熷嚭閮ㄥ垎媧劇敓鍕捐偂鏁?濡?nbsp;6 8 10) 錛?nbsp;2濂囨垨2鍋?br>    
    鐢變簬a[i]<=MAX       MAX= 10^7
    鎵浠ュ繀鏈墄^2-y^2 <= MAX , 2xy <= MAX  浣唜^2+y^2涓嶄竴瀹?lt;= MAX
    2y^2<=MAX
    x^2<=MAX+y^2<=3MAX/2
    => x<=sqrt(3MAX/2) , y <= sqrt(MAX/2)
    鎵浠ユ灇涓緓,y澶嶆潅搴︿負(fù)O(MAX)
    (娉ㄦ剰x,y鏄?濂?鍋朵笖gcd(x,y) = 1)

    鍙傝僿atashi浠g爜鍐欑殑    
*/

#include
<iostream>
#include
<cstring>
#include
<map>
#include
<algorithm>
#include
<stack>
#include
<queue>
#include
<cmath>
#include
<string>
#include
<cstdlib>
#include
<vector>
#include
<cstdio>
#include
<set>
#include
<list>

using namespace std;

const int MAX = 10000000;
const int MAXX = (int)(sqrt(1.5*MAX) + 0.5);
const int MAXN = 1000000;

struct DisjointSet{
    
int fa[MAXN];
    
void init(int n){
        
for(int i = 1 ; i <= n ; i++){
            fa[i] 
= i;
        }

    }

    
int root(int x){
        
return x == fa[x] ? x : fa[x] = root(fa[x]);
    }

    
bool join(int a ,int b){
        a 
= root(a);
        b 
= root(b);
        
if(a != b){
            fa[a] 
= b;
            
return true;
        }

        
return false;
    }

}
;

DisjointSet ds;
int id[MAX+10];

inline 
int gcd(int x , int  y){
    
return  y == 0 ? x : gcd(y , x % y);
}


bool gao(int a , int b){
    
return id[a] > 0 && id[b] > 0 && ds.join(id[a],id[b]);
}


int main()
{
    
for(int n ; ~scanf("%d",&n) ; ){
        fill(id,id
+MAX+1,0);
        ds.init(n);
        
for(int i = 1,x; i <= n ; i++){
            scanf(
"%d",&x);
            id[x] 
= i;
        }

        
for(int x = 1 ; x <= MAXX ; x++){
            
for(int y = x % 2 + 1 ; y < x ; y += 2){
                
if(gcd(x, y) == 1){//need it
                    int a = x*- y*y;
                    
int b = 2*x*y;
                    
int c = x*+ y*y;
                    
if(a > MAX || b > MAX){
                        
continue;
                    }

                    n 
-= gao(a,b);
                    
if(c <= MAX){
                        n 
-= gao(a,c);
                        n 
-= gao(b,c);
                    }

                }

            }

        }

        printf(
"%d\n",n);
    }
        
    
return 0;
}


_Yuan 2011-02-21 11:15 鍙戣〃璇勮
]]>
亚洲精品乱码久久久久66| 国产精品久久久福利| 草草久久久无码国产专区| 亚洲中文字幕无码久久综合网| 伊人丁香狠狠色综合久久| A狠狠久久蜜臀婷色中文网| 久久精品国产免费观看三人同眠| 久久se精品一区二区影院 | 色综合久久无码中文字幕| 香蕉久久AⅤ一区二区三区| 久久AAAA片一区二区| 精品久久久久久久久久久久久久久| 久久久久久亚洲精品成人| 婷婷久久五月天| 久久综合狠狠综合久久97色| 国产亚洲美女精品久久久| 精品无码久久久久久久动漫| 久久成人国产精品一区二区| 久久精品夜色噜噜亚洲A∨| 久久亚洲高清综合| 亚洲人AV永久一区二区三区久久| 欧美久久亚洲精品| 久久经典免费视频| 久久久久久久精品成人热色戒| 怡红院日本一道日本久久| 久久久久国产视频电影| 性做久久久久久免费观看| 久久久久av无码免费网| 亚洲日韩中文无码久久| 久久精品国产亚洲77777| 久久久久综合网久久| 久久精品一区二区三区中文字幕| 欧美色综合久久久久久| 伊人久久综合无码成人网| 99999久久久久久亚洲| 国产精品成人99久久久久91gav| 理论片午午伦夜理片久久 | 久久久久亚洲AV无码麻豆| 91精品国产综合久久久久久| 午夜不卡888久久| 人妻丰满?V无码久久不卡|