A1041】的更多相关文章

Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1, 104]. The first one who bets on a unique number wins. For example, if there are 7…
输入n个数,找出第一个只出现一次的数,输出它. 如果没有,输出none. 思路: 将输入的数值作为HashTable的数组下标即可. #include<cstdio> ], hashTable[]={}; int main(){ int n; scanf("%d", &n); ;i<n;i++){ scanf("%d",&a[i]); hashTable[a[i]]++; } ; ;i<n;i++){//遍历n即可 ){ an…
一.技术总结 这题在思考的时候遇见了,不知道怎么处理输入顺序问题,虽然有记录每个的次数,事后再反过来需要出现一次的且在第一次出现, 这时我们其实可以使用另一个数组用来存储输入顺序的字符,然后再用另一个数组记录出现的次数,这样就可以解决这个问题了. 如果使用cin出现运行超时的情况可以改用scanf,但是这个我运行的时候没有出现超时. 我把下列代码 int number[N]; 改成 int number[10010]; 然后提交出现段错误.不知道什么原因..... 二.参考代码: #includ…
Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1]. The first one who bets on a unique number wins. For example, if there are 7 peopl…
1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1,10​4​​]. The first one who bets on a unique number wins. For…
Source: PAT A1041 Be Unique (20 分) Description: Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1]. The first one who bets on a uniqu…
专题一  字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d",&a,&b); sum=a+b; ) { printf ("-"); sum=-sum; } ; ) { s[top++]=; } ) { s[top++]=sum%; sum/=; } ;i>=;i--) { printf ("%d"…