一道acm题,Delete NumberTime Limit:1000MS Memory Limit:65536KTot
来源:学生作业帮 编辑:大师作文网作业帮 分类:英语作业 时间:2024/11/11 08:49:50
一道acm题,
Delete Number
Time Limit:1000MS Memory Limit:65536K
Total Submit:701 Accepted:129
Description
Given 2 integer number n and m.You can delete m digits from the number n,then number n changes to a new number n1.Tell me how to delete the number,you can get the smallest one.
For example,
m:1 n:1456
n1 may be 145,156,146,456
the smallest one is 145.Then n1 should be 145.
Input
The input consists of T test cases.The number of them (T) is given on the first line of the input file.Each test case consists of one single line containing two integer number m(1
Delete Number
Time Limit:1000MS Memory Limit:65536K
Total Submit:701 Accepted:129
Description
Given 2 integer number n and m.You can delete m digits from the number n,then number n changes to a new number n1.Tell me how to delete the number,you can get the smallest one.
For example,
m:1 n:1456
n1 may be 145,156,146,456
the smallest one is 145.Then n1 should be 145.
Input
The input consists of T test cases.The number of them (T) is given on the first line of the input file.Each test case consists of one single line containing two integer number m(1
1
2 178023
if (*(p-1)>*p&&n>0)
{
del (p-1);
n--;
}
……
if (*(p-1)>*p&&n>0)
{
del (p-1);
n--;
p=str+1;
}
不知道题目在那~没有测试~
再问: 地址:http://acmpj.zstu.edu.cn/JudgeOnline
题目是:2511
还是wa诶,不过178023已经可以了,麻烦再看一下,谢谢。
再答: 1 4 5789123456 #include #include void del (char *p) { while (*p!='\0') { *p=*(p+1); p++; } } int main() { int T;char c; scanf ("%d",&T); while (T--) { char str[1000]; int n; char *p; scanf ("%d",&n); scanf ("%s",str); p=str+1; while (*p!='\0') { if (*(p-1)>*p&&n>0) { del (p-1); n--; p=str+1; continue; } p++; } while (n) { p--; del(p); n--; } while (str[0]=='0') { strcpy(str,str+1); } if(str[0]=='\0')printf("0"); printf ("%s\n",str); } return 0; }
2 178023
if (*(p-1)>*p&&n>0)
{
del (p-1);
n--;
}
……
if (*(p-1)>*p&&n>0)
{
del (p-1);
n--;
p=str+1;
}
不知道题目在那~没有测试~
再问: 地址:http://acmpj.zstu.edu.cn/JudgeOnline
题目是:2511
还是wa诶,不过178023已经可以了,麻烦再看一下,谢谢。
再答: 1 4 5789123456 #include #include void del (char *p) { while (*p!='\0') { *p=*(p+1); p++; } } int main() { int T;char c; scanf ("%d",&T); while (T--) { char str[1000]; int n; char *p; scanf ("%d",&n); scanf ("%s",str); p=str+1; while (*p!='\0') { if (*(p-1)>*p&&n>0) { del (p-1); n--; p=str+1; continue; } p++; } while (n) { p--; del(p); n--; } while (str[0]=='0') { strcpy(str,str+1); } if(str[0]=='\0')printf("0"); printf ("%s\n",str); } return 0; }
一道acm题,Delete NumberTime Limit:1000MS Memory Limit:65536KTot
ACM题一道,原题 zstuoj2511Delete NumberTime Limit:1000MS Memory Li
一道acm题,Problem H:Groups (I)Time Limit:1000MS Memory Limit:65
一道数学的ACM题.1514:x + 2y + 3z = nTime Limit:1000MS Memory Limit
ACM Block world Time Limit:1000ms Memory Limit:65536kb Descr
计算题 Time Limit: 1000MS Memory limit: 65536K
ACM的 “顺”序列 Time Limit:1000MS Memory Limit:32768K
C++ACM竞赛题植树节 Time Limit:1000MS Memory Limit:32768KDescriptio
C语言排序分数题排序分数Time Limit:1000MS Memory Limit:65536KDescription
一道c语言题目棋盘上的距离Time Limit:1000MS Memory Limit:65536KTotal Subm
C语言一道简单的题目An Easy ProblemTime Limit:1000MS Memory Limit:6553
新手请教ACM水题Q - 数据的交换输出Time Limit:1000MS Memory Limit:32768KB 6