惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
B
Blog RSS Feed
阮一峰的网络日志
阮一峰的网络日志
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
MyScale Blog
MyScale Blog
WordPress大学
WordPress大学
Microsoft Azure Blog
Microsoft Azure Blog
GbyAI
GbyAI
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
Martin Fowler
Martin Fowler
Vercel News
Vercel News
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
Microsoft Security Blog
Microsoft Security Blog
G
Google Developers Blog
Last Week in AI
Last Week in AI
Hugging Face - Blog
Hugging Face - Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
云风的 BLOG
云风的 BLOG

博客园 - UnseenstoneX

《打砖块创作家》隐私政策 打砖块创作家《小游戏隐私保护指引》 python 常用数据结构 Python 基本语法 地形遇到几个问题 TArray数组 UE问题分部解决 UE寻找Actor UE对话框 ShadowCaster 代码 C#读写csv文件 优化相关 unity 打开文件夹并鼠标选中某文件 Json解析 C# winform中 选择文件和保存文件 Unity与Android交互实现 C# 持续序列化对象追加到文件的方法 读写文件 C#二进制序列化和反序列化
一个将数据均匀分段1,2,5的随写
UnseenstoneX · 2018-06-12 · via 博客园 - UnseenstoneX
 1 private static List<int> GetXList(int value)
 2     {
 3         List<int> xList=new List<int>();
 4         //将数据粗略分为10-20段,在此区间内寻找余数最小的值
 5         float minResidueRatio=1.01f;//余数
 6         int goalElement=0;
 7         for(int i=10;i<=20;i++)
 8         {
 9             int element=value/i;
10             element=GetXSpace(element);
11             if(value%element==0)
12             {
13                 goalElement=element;
14                 break;
15             }
16             float residueRatio=(float)((value/element+1)*element-value)/(float)element;
17             if(residueRatio<minResidueRatio)
18             {
19                 minResidueRatio=residueRatio;
20                 goalElement=element;
21             }
22         }
23         int segNum=0;//分段数
24         if(value%goalElement==0)
25         segNum=value/goalElement;
26         else
27         segNum=value/goalElement+1;
28         for(int i=0;i<=segNum;i++)
29         {
30             xList.Add(i*goalElement);
31         }
32         return xList;
33         
34     }
35 
36     private static int GetXSpace(int value)
37     {
38         int Digit=GetNumDigit(value);
39         int num=(int)Math.Pow(10,Digit);
40         int []arr={1,2,5};
41         int goal=num;
42         for(int i=0;i<arr.Length;i++)
43         {
44             if(num*arr[i]<=value)
45             {
46                 goal=num*arr[i];
47             }
48             else
49             {
50                 break;
51             }
52             
53         }
54         return goal;
55     }
56 
57     private static int GetNumDigit(int num)
58     {
59         int temp=10; 
60         int count=0;
61         while(temp<num)
62         {
63             temp*=10;
64             count++;
65         }
66         return count;
67     }

posted @ 2018-06-12 15:57  UnseenstoneX  阅读(472)  评论()    收藏  举报