标题:平方十位数
由0~9这10个数字不重复、不遗漏,可以组成很多10位数字。 这其中也有很多恰好是平方数(是某个数的平方)。
比如:1026753849,就是其中最小的一个平方数。
请你找出其中最大的一个平方数是多少?
注意:你需要提交的是一个10位数字,不要填写任何多余内容。
Code/* ^....0 ^ .1 ^1^ .. 01 1.^ 1.0 ^ 1 ^ ^0.1 1 ^ ^..^ 0. ^ 0^ .0 1 .^ .1 ^0 .........001^ .1 1. .111100....01^ 00 11^ ^1. .1^ 1.^ ^0 0^ .^ ^0..1 .1 1..^ 1 .0 ^ ^ 00. ^^0.^ ^ 0 ^^110.^ 0 0 ^ ^^^10.01 ^^ 10 1 1 ^^^1110.1 01 10 1.1 ^^^1111110 010 01 ^^ ^^^1111^1.^ ^^^ 10 10^ 0^ 1 ^^111^^^0.1^ 1....^ 11 0 ^^11^^^ 0.. ....1^ ^ ^ 1. 0^ ^11^^^ ^ 1 111^ ^ 0. 10 00 11 ^^^^^ 1 0 1. 0^ ^0 ^0 ^^^^ 0 0. 0^ 1.0 .^ ^^^^ 1 1 .0 ^.^ ^^ 0^ ^1 ^^^^ 0. ^.1 1 ^ 11 1. ^^^ ^ ^ ..^ ^..^ ^1 ^.^ ^^^ .0 ^.0 0..^ ^0 01 ^^^ .. 0..^ 1 .. .1 ^.^ ^^^ 1 ^ ^0001 ^ 1. 00 0. ^^^ ^.0 ^.1 . 0^. ^.^ ^.^ ^^^ ..0.0 1 .^^. .^ 1001 ^^ ^^^ . 1^ . ^ ^. 11 0. 1 ^ ^^ 0. 0 ^. 0 ^0 1 ^^^ 0. 0.^ 1. 0^ 0 .1 ^^^ .. .1 1. 00 . .1 ^^^ .. 1 1. ^. 0 .^ ^^ .. 0. 1. .^ . 0 . .1 1. 01 . . ^ 0 ^.^ 00 ^0 1. ^ 1 1 .0 00 . ^^^^^^ . .^ 00 01 .. 1. 00 10 1 ^ ^.1 00 ^. ^^^ .1 .. 00 .1 1..01 .. 1.1 00 1. ..^ 10 ^ 1^ 00 ^.1 0 1 1 .1 00 00 ^ 1 ^ . 00 ^.^ 10^ ^^ 1.1 00 00 10^ ..^ 1. ^. 1. 0 1 ^. 00 00 .^ ^ ^. ^ 1 00 ^0000^ ^ 01 1 0 ^. 00.0^ ^00000 1.00.1 11 . 1 0 1^^0.01 ^^^ 01 .^ ^ 1 1^^ ^.^ 1 1 0. .. 1 ^ 1 1 ^ ^ .0 1 ^ 1 .. 1.1 ^0.0 ^ 0 1..01^^100000..0^ 1 1 ^ 1 ^^1111^ ^^ 0 ^ ^ 1 1000^ .1 ^.^ . 00 .. 1.1 0. 0 1. . 1. .^ 1. 1 1. ^0 ^ . ^.1 00 01 ^.0 001. .^ */ // VB_king —— 2017_Finals_A_1.cpp created by VB_KoKing on 2019-05-06:16. /* Procedural objectives: Variables required by the program: Procedural thinking: Functions required by the program: Determination algorithm: Determining data structure: */ /* My dear Max said: "I like you, So the first bunch of sunshine I saw in the morning is you, The first gentle breeze that passed through my ear is you, The first star I see is also you. The world I see is all your shadow." FIGHTING FOR OUR FUTURE!!! */ #include #include using namespace std; void i2s(string &str,long long num) { stringstream ss; ss<<num; ss>>str; } bool check(string str) { if (str.length()!=10) return false; for (int i = 0; i < 10; i++) { if (str.find(i+'0')==string::npos) return false; } return true; } int main() { for (long long i = 30000; i < 100000; i++) { string str; i2s(str,i*i); if (check(str)) cout<<"i="<<i<<" i^2="<<i*i<<endl; } return 0; }