HDU – 4320 Arcane Numbers 1

來源:互聯網
上載者:User

開始的時候沒看懂 a finite decimal,

我以為是有限小數的數, 其實也是...吧....好吧好像這沒什麼關係(因為整數部分各數值可以隨意轉換麼.....雖然我當時抽了以為不可以.....)

但是我沒意識到這是小數的數值轉換, 十進位小數轉二進位是乘二取整麼(注意這裡進位是十進位的).

然後看了兩份題解

http://www.cnblogs.com/Lyush/archive/2012/08/01/2617780.html

http://blog.csdn.net/diannaok/article/details/7815545

然後還無聊去查了下因數跟約數的區別...http://zhidao.baidu.com/question/129997629.html , 差不多, 我的理解是因數不一定是整數.

但質因數總歸是整數了, 而且質因數重複只算一個, 約數個數是每個質因數的指數加一累乘......惡補..

所以這題就是求: B中是否包含A中所有質因數

代碼:

#include<cstdio>#include<cstring>#include<iostream>#include<cmath>#include<string>#include<vector>#include<map>using namespace std;int Rint() { int x; scanf("%d", &x); return x; }#define FOR(i, a, b) for(int i=(a); i<=(b); i++)#define FORD(i,a,b) for(int i=(a);i>=(b);i--)#define REP(x) for(int i=0; i<(x); i++)typedef long long int64;#define INF (1<<30)#define bug(s) cout<<#s<<"="<<sint64 n, m;int64 gcd(int64 x, int64 y){return y==0? x: gcd(y, x%y);}int main(){int t = Rint();for(int T=0; T<t; T++){printf("Case #%d: ", T+1);scanf("%I64d%I64d", &n, &m);for(;;){int64 g = gcd(n, m);if(g!=1){n/=g;}else{if(n == 1)// m包含n所有因數 {printf("YES\n");}else{printf("NO\n");}break;}}}}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.