import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub BigInteger num1, num2; int n; int kc = 1000000000; int l, r, mid, t; Scanner in = new Scanner(System.in); while (in.hasNext()) { n = in.nextInt(); num1 = in.nextBigInteger(); l = 0; r = kc; while (true)//二分 { mid = (l + r) >> 1; num2 = BigInteger.valueOf(mid); num2 = num2.pow(n); t = num2.compareTo(num1); if (t == 0) { System.out.println(mid); break; } else if (t > 0) r = mid - 1; else l = mid + 1; } } } }
#include <iostream> #include <fstream> #include <cstring> #include <string> #include <algorithm> #include <iomanip> #include <cstdio> #include <cstdlib> #include <cmath> using namespace std; int main() { long long int n, nt, mid, x, y; while (cin>>n, n) { x = y = nt = ceil(sqrt(n)); mid = (nt * nt + (nt - 1) * (nt - 1) + 1) >> 1;/**< long long 防止mid超了 */ //cout<<mid<<endl; if (n != mid) { if (n > mid) { if (nt & 1)/**< n为奇数, 从左到右,再下 在左边*/ { x = x - n + mid; } else/**< 从下到上再到左 在下边*/ { y = y - n + mid; } } else { if (nt & 1)/**< n为奇数, 从左到右,再下 在下边*/ { y = y + n - mid; } else/**< 从下到上再到左 在左边*/ { x = x + n - mid; } } } cout<<x<<' '<<y<<endl; } return 0; }
#include <iostream> #include <fstream> #include <cstring> #include <string> #include <algorithm> #include <iomanip> #include <cstdio> #include <cstdlib> #include <cmath> using namespace std; char s[8], ts[8]; int a[][6] =/**< 枚举,总共24种情况, 在枚举中可以发现(1, 6)(2, 5)(3, 4)两两一组, 当其中一组换位置时,另外两组中必须只有一组需要换位置, 或者但两组互换时,其中一组也要换位置 */ { 1, 6, 2, 5, 3, 4, 1, 6, 5, 2, 4, 3, 1, 6, 3, 4, 5, 2, 1, 6, 4, 3, 2, 5, 6, 1, 5, 2, 3, 4, 6, 1, 2, 5, 4, 3, 6, 1, 4, 3, 5, 2, 6, 1, 3, 4, 2, 5, 2, 5, 6, 1, 3, 4, 2, 5, 1, 6, 4, 3, 2, 5, 3, 4, 1, 6, 2, 5, 4, 3, 6, 1, 5, 2, 1, 6, 3, 4, 5, 2, 6, 1, 4, 3, 5, 2, 4, 3, 1, 6, 5, 2, 3, 4, 6, 1, 3, 4, 2, 5, 6, 1, 3, 4, 5, 2, 1, 6, 3, 4, 1, 6, 2, 5, 3, 4, 6, 1, 5, 2, 4, 3, 2, 5, 1, 6, 4, 3, 5, 2, 6, 1, 4, 3, 6, 1, 2, 5, 4, 3, 1, 6, 5, 2 }; bool fun() { int i, j; for (i = 1; i < 24; i++) { for (j = 0; j < 6; j++) if (s[a[0][j]] != ts[a[i][j]]) break; if (j == 6) return true; } return false; } int main() { int i = 1; while (cin>>s[i++]) { for (; i < 7; i++) cin>>s[i]; s[i] = '