luyencode / comments

Server lưu trữ bình luận trên Luyện Code
https://luyencode.net
6 stars 3 forks source link

https://oj.luyencode.net/problem/NPALIN1 #694

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Chi tiết bài tập - Luyện Code Online

https://luyencode.net/problem/NPALIN1

nguyenkien0703 commented 2 years ago

em xin code vs

higuysbyelady commented 2 years ago

Lúc đầu mình làm theo cách bình thường thì nhận ra quy luật của nó như sau vd: input: 1 2 3 4 5 6 7 8..... output: 9 9 90 90 900 900 9000 9000.....

Bài code AC của mình

#include using namespace std; int main() { int a[17]; int i,j; a[1]=9; a[2]=9; for(i=3, j=4; i<=15||j<=16;i=i+2, j=j+2) { a[i]=a[i-2]*10; a[j]=a[i]; } int n; while(cin>>n) { cout<

vitegod commented 2 years ago

Dễ thấy 1 số đối xứng muốn tạo ra thì chỉ cần tạo 1 nửa của nó tức là ví dụ số có 3 chữ số thì chỉ cần tạo 10 11 12 rồi lật lại thành 101 111 121 nên muốn tạo số có n chữ số cần 9 cách chọn số đầu, 10 cách chọn các số còn lại, còn số lượng cần thì tự tính https://luyencode.net/status/6b70f7184617ec6f3033a490406fbe3c?problem=NPALIN1

ghost commented 2 years ago

Đây là lời giải của mình đã AC. Nếu bạn đã cố gắng mà chưa làm được thì có thể tham khảo lời giải của mình. One hit AC with - Phân Tích =))

Xem code AC

```cpp #include using namespace std; // Topic variable. int n; // Auxiliary variable. int ans[9] = {0, 9, 90, 900, 9000, 90000, 900000, 9000000, 90000000}; //___________________ int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); while (cin >> n) { cout << ans[(n+1) / 2] << endl; } return 0; } ```

danh2006 commented 1 year ago

Đây là lời giải của mình đã AC. Nếu bạn đã cố gắng mà chưa làm được thì có thể tham khảo lời giải của mình.

Xem code AC

// Code hoi troll #include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, a[15]; a[1]=a[2]=9, a[3]=a[4]=90, a[5]=a[6]=900, a[7]=a[8]=9000, a[9]=a[10]=90000, a[11]=a[12]=900000, a[13]=a[14]=9000000, a[15]=90000000; while(cin >> n){ cout << a[n] << endl; } return 0; }

ThuanNqt commented 1 year ago

Đây là lời giải của mình đã AC. Nếu bạn đã cố gắng mà chưa làm được thì có thể tham khảo lời giải của mình.

Xem code AC

#include using namespace std; typedef long long ll; int main(){ int n; while(cin>>n){ int a[20]; a[1]=a[2]=9; for(int i=3;i<20;i++){ if(i%2!=0){ a[i]=a[i-1]*10; }else{ a[i]=a[i-1]; } } for(int i=1;i<=15;i++){ if(n==i){ cout<

ZipTGhz commented 1 year ago

Đây là lời giải của mình đã AC. Nếu bạn đã cố gắng mà chưa làm được thì có thể tham khảo lời giải của mình.

Xem code AC

```cpp #include #include int main() { int n; while (scanf("%d", &n) == 1) { if (n == 1 || n == 2) printf("9\n"); else printf("%lli\n", 9 * (long long) pow(10,((int) (n - 1) / 2))); } } ```

KietBigDock2006 commented 1 year ago

Đây là lời giải của mình đã AC. Nếu bạn đã cố gắng mà chưa làm được thì có thể tham khảo lời giải của mình.

Xem code AC

program sodoixun; type arr = array[1..15] of byte; var n, res, m, i: longint; x: arr; s: ansistring; arrres: array[1..15] of int64; procedure printf; var i: longint; begin for i := 1 to m do write(x[i]); writeln; end; procedure try(i: longint); var j: longint; begin if i = 1 then for j := 1 to 9 do begin x[i] := j; if i = m then inc(res) else try(i+1); end else for j := 0 to 9 do begin x[i] := j; if i = m then inc(res) else try(i+1); end; end; begin for i := 1 to 15 do begin if i mod 2 = 0 then m := i div 2 else m := i div 2 + 1; try(1); arrres[i] := res; res := 0; end; while true do begin readln(s); if s = '' then break; val(s, n); writeln(arrres[n]); end; end.