Nộp bài | Các bài nộp | Làm tốt nhất | Về danh sách bài |
Được gửi lên bởi: | adm |
Ngày: | 2011-10-19 |
Thời gian chạy: | 1s |
Giới hạn mã nguồn: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Ngôn ngữ cho phép: | ASM32-GCC ASM32 MAWK BC C CSHARP C++ 4.3.2 CPP CPP14 COFFEE LISP sbcl DART FORTH GO JAVA JS-RHINO JS-MONKEY KTLN OCT PAS-GPC PAS-FPC PERL PERL6 PROLOG PYTHON PYTHON3 PY_NBC R RACKET SQLITE SWIFT UNLAMBDA |
hide comments
|
||||||
2023-08-13 02:26:06
t=int(input()) while t: t-=1 stt,a=input().split() a=[int(i) for i in a] n=len(a) ok=False i=n-2 while i>=0 and a[i]>=a[i+1]: i-=1 if i==-1: ok=True else: j=n-1 while a[j]<a[i]: j-=1 a[i],a[j]=a[j],a[i] l=i+1 r=n-1 while l<r: a[l],a[r]=a[r],a[l] r-=1 l+=1 if ok: print(stt,'BIGGEST') else: print(stt,''.join([str(i) for i in a])) Ai đó kiểm tra hộ mình xem sai đâu được k ạ. chạy ngoài đúng rồi mà up lên báo làm sai. k hiểu chỗ nhập với in ra mình sai như tnao |
||||||
2021-01-23 03:55:26
cho mình hỏi lỗi segmentation(lỗi ohaan đoạn) phải sửa như nào vậy ạ? Code mình: #include<bits/stdc++.h> using namespace std; int HoanViKeTiep(string a){ int tg, b[80], j = 0, viTriDung, c; for(int i = a.length() - 1; i > 0; i--){ if(a[i] <= a[i - 1]){ b[j] = a[i] - 48; j++; if(i==1){ cout << "BIGGEST"; return 0; } } else { b[j] = a[i] - 48; viTriDung = i; c = a[i - 1] - 48; break; } } for(int k = 0; k <= j; k++){ if(b[k] > c){ tg = c; c = b[k]; b[k] = tg; break; } } for(int i = 0; i < viTriDung-1; i++){ cout << a[i]; } cout << c; for(int i = 0; i <= j; i++){ cout << b[i]; } } int main(){ int n;//n la so bo test cin >> n; int boTestSo[1000]; string a[80]; for(int i = 1; i <= n; i++){ cin >> boTestSo[i] >> a[i]; } for(int i = 1; i <= n; i++){ cout << boTestSo[i] << " "; HoanViKeTiep(a[i]); //bo test so i phai cung dong vs string a[i] cout << endl; } } |
||||||
2019-09-16 10:53:45
Last edit: 2019-09-16 11:03:25 |
||||||
2019-08-25 06:22:32
Tham Khao Code: http://ideone.com/ec7SPu |
||||||
2018-09-05 05:18:27
Chia sẻ tài liệu học C/C++ từ cơ bản đến nâng cao : https://licklink.net/eUvSt |
||||||
2018-07-28 12:19:48
https://www.youtube.com/watch?v=H9EwB0zpkco&feature=youtu.be |
||||||
2018-06-07 05:08:06
Sao mình chạy tất cả các test đúng mà biên dịch vẫn báo sai nhỉ....Help import java.util.Scanner; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author HoangNM */ class B { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int count = 0; while (count < n) { int x = sc.nextInt(); System.out.print(x+" "); String s = sc.nextLine(); s=s.substring(1); int leng=s.length(); int a[] = new int[100]; for (int i = 0; i < leng; i++) { a[i] =s.charAt(i)-'0'; } Boolean isBigest=true; for (int i = leng - 2; i >= 0; i--) { if (a[i] < a[i + 1]) { isBigest=false; int k=i+1; for (int j = leng-1; j >=k; j--) { if (a[i]<a[j]) { int t=a[i]; a[i]=a[j]; a[j]=t; break; } } int j=i+1; int r=leng-1; while(j<=r){ int t=a[j]; a[j]=a[r]; a[r]=t; j++; r--; } break; } } if(isBigest){ System.out.print("BIGGEST"); }else{ for(int i=0;i<leng;i++){ System.out.print(a[i]); } } System.out.println(""); count++; } } } |
||||||
2018-04-22 19:31:18
Try next_permutation which is defined in header<algorithm> |
||||||
2018-01-29 08:44:37
.... |
||||||
2018-01-24 16:10:38
đề không bắt nhập n thì phải đếm à ? |