LeetCode Biweekly Contest 5
問題文
省略
省略
#include<bits/stdc++.h>
using namespace std;
template<class T, class S> inline T pow_L(T a, S b){
T res=1;
res = 1;
while(b){
if(b&1){
res *= a;
}
b >>= 1;
a *= a;
}
return res;
}
class Solution{
public:
bool isArmstrong(int N){
long long d, k, r;
d = 0;
k = N;
while(k){
k/=10;
d++;
}
r = 0;
k = N;
while(k){
r +=pow_L((k%10),d);
k /= 10;
}
return r==N;
}
}
;
// cLay varsion 20190802-1
// --- original code ---
// class Solution {
// public:
// bool isArmstrong(int N) {
// ll k, d, r;
//
// d = 0;
// k = N;
// while(k) k/=10, d++;
//
// r = 0;
// k = N;
// while(k){
// r += (k%10) ** d;
// k /= 10;
// }
//
// return r==N;
// }
// };
//
// {
// // main関数を適当に処理する
// }
Current time: 2024年04月26日04時07分42秒
Last modified: 2019年08月10日16時43分14秒 (by laycrs)
Tags: Competitive_Programming_Incomplete LeetCode
トップページに戻る
Logged in as: unknown user (not login)