#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define eps 1e-8
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a/gcd(a,b)*b
#define lowbit(x) (x&-x)
#define all(x) x.begin(), x.end()
#define debug(x...) do { cout<< #x <<" -> "; re_debug(x); } while (0)
void re_debug() { cout<<'\n'; }
template<class T, class... Ts> void re_debug(const T& arg,const Ts&... args) { cout<<arg<<" "; re_debug(args...); }
void cut(){ cout<<'\n'<<"------------"<<'\n';}
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
const int INF=0x3f3f3f3f;
const ll LNF=0x3f3f3f3f3f3f3f3fll;
const double PI=acos(-1.0);
void solve()
{
}
int main()
{
IOS;
int T=1;
cin>>T;
while(T--) solve();
return 0^0;
}
//注意: 解绑之后不能使用getchar(),scanf(),printf等
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
IOS;
//unique 将重复元素放在后面+1的位置然后到原来的数组后面然后后面全部抹掉
//先排序,再去重
vector<int> q(n);
sort(q.begin(),q.end());
q.erase(unique(q.begin(),q.end()),q.end());
//返回的是地址,减去首地址,就是下标,时间复杂度O(n)
vector<int> q;
for(int i=1;i<100;i++) q.push_back(i);
int maxn=max_element(q.begin(),q.end())-q.begin();
int minn=min_element(q.begin(),q.end())-q.begin();
cout<<q[maxn]<<' '<<q[minn]<<'\n';
//仅在linux上可以使用
__int128 read()
{
__int128 x=0,f=1;
char ch=getchar();
while(!isdigit(ch)&&ch!='-')ch=getchar();
if(ch=='-')f=-1;
while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
return f*x;
}
void print(__int128 x)
{
if(x<0)putchar('-'),x=-x;
if(x>9)print(x/10);
putchar(x%10+'0');
}
//输出一个数字二进制中有多少个1
//常数非常小
int n=2;
cout<<__builtin_popcount(n)<<'\n';
//先srand()一下,然后rand_shuffle()
vector<int> q;
for(int i=0;i<10;i++) q.push_back(i);
srand(time(NULL));
random_shuffle(q.begin(),q.end());
//过滤其中很多的回车, <题目: 估值一亿的AI核心代码>
//请将同步流开启,否则不能读入,可以读很多,都能读
//以字符串读入,但是可以读入数字等
//ios::sync_with_stdio(false);
//cin.tie(nullptr);
//记住:要吞掉前面的空格
string s;
getline(cin,s);//可以使用cin.get() 代替,这样可以不取消同步流
stringstream ssin(s);
string t;
vector<string> q;
while(ssin>>t)
{
q.push_back(t);
}
vector<int> q;
for(int i=100;i>=1;i--) q.push_back(i);
if(is_sorted(q.begin(),q.end())) cout<<"判断升序"<<'\n';
if(is_sorted(q.begin(),q.end(),greater<int>())) cout<<"判断降序"<<'\n';
vector<int> q;//不太懂,建议手写
for(int i=1;i<=10;i++) q.push_back(i);
//三个参数: 开始,哪一个参数放在前面,终止 然后循环
rotate(q.begin(),q.begin()+2,q.end());
string s;
cin>>s;
for(int i=0;i<s.size();i++)
{
s[i]=char(toupper(s[i]));
//或者
//s[i]=char(tolower(s[i]));
}
cout<<s<<'\n';
#pragma GCC optimize(2)//建议只开O2就行了
#pragma GCC optimize(3,"Ofase","inline")
struct cmp
{
long long operator()(pair<int,int> x)const
{
return 1ll*x.first*521417+x.second;//return的就是相关重载,可以尽量写复杂点,
}
};
unordered_map<pair<int,int>,int,cmp> umap;
我正在使用puppet为ruby程序提供一组常量。我需要提供一组主机名,我的程序将对其进行迭代。在我之前使用的bash脚本中,我只是将它作为一个puppet变量hosts=>"host1,host2"我将其提供给bash脚本作为HOSTS=显然这对ruby不太适用——我需要它的格式hosts=["host1","host2"]自从phosts和putsmy_array.inspect提供输出["host1","host2"]我希望使用其中之一。不幸的是,我终其一生都无法弄清楚如何让它发挥作用。我尝试了以下各项:我发现某处他们指出我需要在函数调用前放置“function_”……这
我正在使用Mandrill的RubyAPIGem并使用以下简单的测试模板:testastic按照Heroku指南中的示例,我有以下Ruby代码:require'mandrill'm=Mandrill::API.newrendered=m.templates.render'test-template',[{:header=>'someheadertext',:main_section=>'Themaincontentblock',:footer=>'asdf'}]mail(:to=>"JaysonLane",:subject=>"TestEmail")do|format|format.h
所以这可能有点令人困惑,但请耐心等待。简而言之,我想遍历具有特定键值的所有属性,然后如果值不为空,则将它们插入到模板中。这是我的代码:属性:#===DefaultfileConfigurations#default['elasticsearch']['default']['ES_USER']=''default['elasticsearch']['default']['ES_GROUP']=''default['elasticsearch']['default']['ES_HEAP_SIZE']=''default['elasticsearch']['default']['MAX_OP
一般来说,我是Middleman和ruby的新手。我已经安装了Ruby我已经安装了Middleman和gem以使其运行。我需要使用slim而不是默认的模板系统。所以我安装了Slimgem。Slim的网站只说我需要'slim'才能让它工作。中间人网站说我只需要在config.rb文件中添加模板引擎,但是没有给出例子...对于没有ruby背景的人来说,这没有帮助。我在git上找了几个config.rb,它们都有:require'slim'和#Setslim-langoutputstyleSlim::Engine.set_default_options:pretty=>true#Se
我有一个偏爱:如何将像o.office这样的值插入到属性中?value="#{o.office}"无效。 最佳答案 'type='text'/>或者你可以使用表单助手 关于ruby-on-rails-如何将变量值插入ERB模板中的HTML标签?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/6172174/
有没有办法在liquidtemplate中输出(用于调试/信息目的)可用对象和对象属性??也就是说,假设我正在使用jekyll站点生成工具,并且我在我的index.html模板中(据我所知,这是一个液体模板)。它可能看起来像这样{%forpostinsite.posts%}{{post.date|date_to_string}}»{{post.title}}{%endfor%}是否有任何我可以使用的模板标签会告诉我/输出名为post的变量在此模板(以及其他模板)中可用。此外,是否有任何模板标签可以告诉我post对象具有键date、title、url、摘录、永久链接等
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visitthehelpcenter.关闭11年前。哪些模板引擎/模板语言是图灵完备的?到目前为止,我听说过这些:FreeMarker(用java实现)MovableTypes模板语言(perl)xslt:-(Cheetah(Python语言)聪明(PHP)还有其他的(特别是用perl实现的)吗?Ps:不要浪费时间向我解释MVC,以及为什么图灵完整模板不好,以及为什么这不是一个有用的比较点:)
我知道我可以用这段代码迭代liquid模板中的数组:{%foriteminmyarray%}{{item.label}}但是我怎样才能得到我的项目在数组中的索引呢? 最佳答案 根据"LiquidforDesigners"liquid的github部分...forloop.length#=>lengthoftheentireforloopforloop.index#=>indexofthecurrentiterationforloop.index0#=>indexofthecurrentiteration(zerobased)forl
究竟如何使用Liquid中的map过滤器?我在Jekyll中使用它。---my_array:[apple,banana,orage]my_map:hello:worldfoo:barmy_string:"howdoesthiswork?"---{{page.my_map|map...}}这就是我迷路的地方。我似乎无法在文档或任何其他在线网站上找到任何关于它的用法示例。顺便说一下,我还不懂Ruby,所以sourcecode我也不清楚。来自filtertests看起来下面应该产生一些东西,但在GitHub上,我什么也没得到:{{site.posts|map:'title'|array_to
我有一些nginx站点的资源和提供程序,它可以为站点写出配置文件。action:startdotemplate"/etc/nginx/sites-enabled/my_site"dosource"nginx_site.conf.erb"notifies:reload,"service[nginx]"endend当我从另一本Recipe中使用它时,找不到模板nginx_site.conf.erb,因为Chef正在寻找调用此资源的模板。有没有办法告诉Chef在nginx资源和提供者Recipe中寻找模板? 最佳答案 您可以为templa