`
猫太的鱼
  • 浏览: 233478 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

1002 better one

c 
阅读更多
#include <stdio.h>
#include <stdlib.h>

char s[31];

int hash()
{
        int sum = 0, i, k;

        for (i = 0, k = 0;k < 7;i++) {
                if (s[i] >='0' && s[i] <='9') {
                        sum *= 10;
                        k++;
                        sum += (s[i] - '0');
                } else if (s[i] >='A' && s[i] < 'Z') {
                        sum *= 10;
                        k++;
                        sum += ((s[i] - 'A' - (s[i] > 'Q')) / 3 + 2);
                }
        }

        return sum;
}

int mycompare(const void *a, const void *b)
{
        return (*(int*)a - *(int*)b);
}

int main(void)
{
        int len, i, num;
        int *data = NULL;
        int flag = 0;

        scanf("%d",&len);
        data = (int*)malloc(len*sizeof(int));

        for (i = 0;i < len;i++) {
                scanf("%s",s);
                data[i] = hash();
        }

        qsort(data,len,sizeof(int),mycompare);          /* It is API in stdlib */
        for (i = 0,num = 1;i < len;i+=num=1) {
                while (data[i] == data[i+1]) {
                        num++;
                        i++;
                }
                if (num > 1) {
                        printf("%03d-%04d %d\n", data[i]/10000, data[i]%10000, num);
                        flag = 1;
                }
        }
        if (flag == 0)
                printf("No duplicates.\n");

        free(data);
        return 0;
}


分享到:
评论

相关推荐

    Two thresholds are better than one

    一片双阈值分割的论文,利用了MRF以及模拟退火算法,对噪声图像的分割效果比较好

    dayone:Better Touch Tool创建DayOne日记条目

    DayOne CLI Better Touch Tool创建DayOne日记条目我创建了一个更好的触摸工具键盘快捷键,以将突出显示的文本保存到DayOne日记中。 我一直在使用它来保存文本片段以供以后使用。 我喜欢DayOne如何将当前日期和时间...

    ComponentOne Studio for ActiveX 2012 v3 4/4

    Applications targeting 64-bit experience better performance with larger available memory allocation. This means you can process larger datasets into charts and grids more efficiently because a 64-bit...

    ComponentOne Studio for ActiveX 2012 v3 3/4

    Applications targeting 64-bit experience better performance with larger available memory allocation. This means you can process larger datasets into charts and grids more efficiently because a 64-bit...

    ComponentOne Studio for ActiveX 2012 v3 2/4

    Applications targeting 64-bit experience better performance with larger available memory allocation. This means you can process larger datasets into charts and grids more efficiently because a 64-bit...

    CRISPRi, One Technology Better than CRISPR-Cas9

    The researchers used an improved version of CRISPR called CRISPRi (CRISPR interference) to allow iPSCs and genes in the heart of iPSCs to be inactivated.

    ComponentOne Studio for WinForms 2013 v1 1/5

    Can now show Progress lines for individual tasks, which allows end-users to better monitor tasks that are ahead or behind schedule. Scheduler With the Scheduler control, you can now view the next ...

    ComponentOne Studio for ActiveX 2012 v3 1/4

    Applications targeting 64-bit experience better performance with larger available memory allocation. This means you can process larger datasets into charts and grids more efficiently because a 64-bit...

    ComponentOne Studio for WinForms 2013 v1

    Can now show Progress lines for individual tasks, which allows end-users to better monitor tasks that are ahead or behind schedule. Scheduler With the Scheduler control, you can now view the next ...

    Attribute Weighting for Averaged One-Dependence Estimators

    Averaged One-Dependence Estimators (AODE) is one of supervised learning algorithm, which relaxes the conditional independent assumption that working on the standard naive Bayes learner. The AODE has ...

    ComponentOne Studio for WinForms 2013 v1 5/5

    Can now show Progress lines for individual tasks, which allows end-users to better monitor tasks that are ahead or behind schedule. Scheduler With the Scheduler control, you can now view the next ...

    ComponentOne Studio for WinJS - Beta

    Based on our popular HTML5 tools in Wijmo and designed to enhance the rich user experience of the Windows 8 platform, these controls... help you build better and more compelling Windows Store apps....

    EWA.zip_The One And Only_cauchy mutation_earthworm_metaheuristic

    Earthworms can aerate the soil with their burrowing action and enrich the soil with ... The results show that EWA23 performs the best and it can find the better fitness on most benchmarks than others.

    two-are-better-than-one:与论文相关的代码**两个比一个好

    自述文件在EMNLP 2020上,与论文“两个优于一个”相关的代码:使用表序列编码器的联合实体和关系提取纳维资源数据集位于“ ./datasets/”中。由于版权问题,我们无法直接发布ACE数据集,而是将其预处理脚本放在“ ./...

    OneDrive_VersionHistoryCleaner:用于从 OneDrive 中删除 VersionHistory 的 PowerShell 脚本

    使用rclone cleanup OneDrive:/path better new 自 rclone v1.52。 这个项目从现在开始被弃用并存档 OneDrive 版本历史清理器 Rhilip 的 PowerShell 脚本 MOD。 !!! 注意所有版本历史将在没有确认的情况下删除...

    mmc_2440_handheld.org.rar_2440_2440 linux_better_samsung_sd driv

    The sd/mmc driver of linux 2.4.20 , it is much better than the one form samsung (good performance)

    ComponentOne Studio for WinRT XAML2012 v3

    ComponentOne Studio for WinRT XAML2012 v3 Powerful WinRT XAML controls for building better Windows Store apps. Powerful UI and Data Visualization Controls for the Windows Store Get UI controls ...

    ImagesBy360.zip

    There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better ...

    单元测试框架.txt

    There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *...

    ComponentOne Studio for Windows Phone 2013 v1

    Designed to enhance the rich user experience of the Windows Phone 8, these Silverlight controls give you powerful and unique functionality to help you build better and more compelling apps. ...

Global site tag (gtag.js) - Google Analytics